392. Is Subsequence
All prompts are owned by LeetCode. To view the prompt, click the title link above.
First completed : June 21, 2024
Last updated : June 21, 2024
Related Topics : Two Pointers, String, Dynamic Programming
Acceptance Rate : 48.034 %
class Solution {
public boolean isSubsequence(String s, String t) {
if (s.length() == 0)
return true;
int sPointer = 0;
for (int tPointer = 0; tPointer < t.length(); tPointer++) {
if (s.charAt(sPointer) == t.charAt(tPointer)) {
sPointer++;
if (sPointer >= s.length())
return true;
}
}
return false;
}
}