bool isSubsetOf(const string& s, const string& t)
{
if(s.length() > t.length())
return false;
vector<int> table(256,0);
int cur = 0;
for(int i=0;i<s.length();++i)
{
if(table[s[i]] > 0) // if the char has been checked in t, decrease the counter by 1
{
--table[s[i]];
continue;
}
else if(cur == t.length())
return false;
while(cur < t.length())
{
if(t[cur] != s[i])
{
++table[t[cur]];
++cur;
}
else
{
++cur;
break;
}
}
}
return true;
}