radhe radhe || greedy simple and easy solution || beats 100%
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    vector<int> validSequence(string w1, string w2) {\n        int n=w1.size(),m=w2.size(),cnt=0;\n        vector<int> pre(n,0),suf(n,0),ans;\n        for(int i=n-1,j=m-1;i>=0;i--){\n            if(j>=0&&w1[i]==w2[j])cnt++,j--;\n            suf[i]=cnt;\n        }\n        cnt=0;\n        for(int i=0,j=0;i<n;i++){\n            if(j<m&&w1[i]==w2[j])cnt++,j++;\n            pre[i]=cnt;\n        }\n        for(int i=0,j=0;i<n&&j<m;i++){\n            if(w1[i]==w2[j]){\n                ans.push_back(i);\n                j++;\n                continue;\n            }\n            int val=((i)?pre[i-1]:0)+((i+1<n)?suf[i+1]:0)+1;\n            if(val>=m){\n                ans.push_back(i);\n                j++;\n                for(int k=i+1;k<n&&j<m;k++){\n                    if(w1[k]==w2[j]){\n                        ans.push_back(k);\n                        j++;\n                    }\n                }\n                break;\n            }\n            if(ans.size()==m)return ans;\n        }\n        if(ans.size()==m)return ans;\n        return {};\n;    }\n};\n```
['C++']