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

# 05/20/2022 392. Is Subsequence

Need to read the articles carefully!!!!

Method:

```
// Some code
class Solution {
    public boolean isSubsequence(String s, String t) {
    
        if (s.length() > t.length()) return false;
        int i = 0; 
        int j = 0;
        while (i < s.length() && j < t.length()){
            if (s.charAt(i) != t.charAt(j)){
                j++;
            } else{
                i++;
                j++;
            }//need to optimized
            
        }
        if (i == s.length()) return true;
        return false; //need to optimized
    }
}
```

```
// Some code
class Solution {
    public boolean isSubsequence(String s, String t) {
    
        if (s.length() > t.length()) return false;
        int i = 0; 
        int j = 0;
        while (i < s.length() && j < t.length()){
            if (s.charAt(i) == t.charAt(j))
                i++;
            j++;     
        }
        return i == s.length();
    }
}
```
