392. 判断子序列
1 class Solution 2 { 3 public: 4 bool isSubsequence(string s, string t) 5 { 6 int n = s.size(); 7 int i = 0; 8 for(int j = 0;j < t.size();j ++) 9 { 10 if(s[i] == t[j]) i++; 11 } 12 return i == n; 13 } 14 };
Mamba never out
1 class Solution 2 { 3 public: 4 bool isSubsequence(string s, string t) 5 { 6 int n = s.size(); 7 int i = 0; 8 for(int j = 0;j < t.size();j ++) 9 { 10 if(s[i] == t[j]) i++; 11 } 12 return i == n; 13 } 14 };