Skip to content

Instantly share code, notes, and snippets.

@eclipselu
Created September 9, 2016 02:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eclipselu/cffe365abaf826307d73b0df512b7ace to your computer and use it in GitHub Desktop.
Save eclipselu/cffe365abaf826307d73b0df512b7ace to your computer and use it in GitHub Desktop.
Is Subsequence
class Solution {
public:
bool isSubsequence(string s, string t) {
queue<char> q;
for (char ch: s)
q.push(ch);
for (char ch: t) {
if (q.empty())
break;
if (ch == q.front())
q.pop();
}
return q.empty();
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment