100% beat
Code\ncpp []\nclass Solution {\npublic:\n    void help(string s,string t,int in,int i,vector<int>&ans){\n        while(in<t.size() && i<s.size()){\n            
# Code\n```cpp []\nclass Solution {\npublic:\n    void help(string s,string t,int in,int i,vector<int>&ans){\n        while(in<t.size() && i<s.size()){\n            if(t[in]==s[i])ans.push_back(i),in++;\n            i++;\n        }   \n    }\n    vector<int> validSequence(string word1, string word2) {\n        vector<int>ans;\n        int i=0;\n        while(i<word2.size() && word1[i]==word2[i])ans.push_back(i),i++;\n        if(i==word2.size())return ans;\n        vector<int>suf(word2.size(),-1);\n        int in=word2.size()-1;\n        for(int j=word1.size()-1;j>=0 && in>=0;j--){\n            if(word1[j]==word2[in])suf[in]=j,in--;\n        }\n        suf.push_back(INT_MAX); \n        in=i;\n        // for(int &i:suf)cout<<i<<" ";\n        // cout<<endl;\n        for(int k=i;in<word2.size() && k<word1.size();k++){\n            if(suf[in+1]>k){\n                ans.push_back(k);\n                help(word1,word2,in+1,k+1,ans);\n                return ans;\n            }\n            if(word1[k]==word2[in])ans.push_back(k),in++;\n        }\n        if(ans.size()!=word2.size())return {};\n        return ans;\n    }\n};\n```
['C++']