> For the complete documentation index, see [llms.txt](https://timmybeeflin.gitbook.io/cracking-leetcode/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://timmybeeflin.gitbook.io/cracking-leetcode/two-pointer/392.-is-subsequence.md).

# 392. Is Subsequence

![](/files/-MehR7sK08WUNum7fZpR)

![](/files/-MehRHy65OGnBtTGTtBr)

time: O(n)

space: O(1)

```java
class Solution {
    public boolean isSubsequence(String s, String t) {
        if (s.length() == 0) return true;
        
        int i = 0;
        for (char c : t.toCharArray()) {
            if (c == s.charAt(i)) i++;
            if (i == s.length()) return true;
        }
        return false;
    }
}


```

## follow up
