Hi, I solved the Leetcode problem 392.
It's about comparing two strings.
s should be a subsequence of t, and we have to consider the order,
but the characters in s can appear separately within t.
To summarize, it's just about checking if s is a subsequence.
Please read the description.
Why is the first example 'true'?
It's because s is a subsequence of t,
even if the characters are not contiguous.
However, in Example 2,
the output is false
because there is no 'x'."
here is my solution
I just need to check if the factor of s consists of t or not.
So, I used the for loop and lf statement for comparing the both of factors.
and declared a variable outside the for loop, because for processing the for loop statement, the variable should be changed.
Then, I plan to use a ternary operator in the return part.
'열정가득한 개발자의 이야기 > Javascript Algorithm' 카테고리의 다른 글
1207. Unique Number of Occurrences (Javascript) (0) | 2024.09.29 |
---|---|
3005. Count Elements With Maximum Frequency (javascript) (3) | 2024.09.28 |
58. Length of Last Word (Javascript) (1) | 2024.09.22 |