s = "abc", t = "ahbgdc"
Return true.
不可改变字符的相对位置
public boolean isSubsequence(String s, String t) {
//双指针法
int si = 0, ti = 0;
char[] snew = s.toCharArray(), tnew = t.toCharArray();
while(si < s.length() && ti < t.length()) {
if(snew[si] == tnew[ti]) {
si ++;
ti ++;
}
else {
ti ++;
}
}
return si == s.length();
}