```
public class Solution {
public boolean isSubsequence(String s, String t) {
int dp = 0;
for(int i=0; i<t.length() && dp<s.length(); i++){
dp= dp + (s.charAt(dp)==t.charAt(i) ? 1 : 0);
}
return dp == s.length();
}
}
```

dp is the length of the largest prefix of s that is a subsequence of t.substring(0, i+1)