Week Training: 392 Is Subsequence

xiaoxiao2021-02-28  116

An easy task, even no using of DP, just increase the t counter when different or increase both when same.

class Solution { public: bool isSubsequence(string s, string t) { int i=0,j=0; while(j<t.length()){ if(s[i]==t[j]){ i++; j++; } else j++; } if(i==s.length()) return true; else return false; } };

转载请注明原文地址: https://www.6miu.com/read-63988.html

最新回复(0)