Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- bool isSubsequence(string s, string t) {
- int i=0,j=0;
- bool f=false;
- if(s.length()==0)
- {
- return true;
- }
- while(i<t.length() && j<s.length())
- {
- if(t[i]==s[j])
- {
- i++;
- j++;
- f=true;
- }
- else
- {
- i++;
- f=false;
- }
- }
- if(f && j==s.length())
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment