1 2 3 4 5 6 7 8 9 10 11 12 13 14
| class Solution { public boolean isSubsequence(String s, String t) { int p1 = 0, p2 = 0; while (p1 < s.length() && p2 < t.length()) { if (s.charAt(p1) == t.charAt(p2)) { p1++; p2++; } else { p2++; } } return p1 == s.length(); } }
|