C++ | Greedy Sol | O(N)
Code

# Code
```cpp []
class Solution {
public:
    vector<int> validSequence(string word1, string word2) 
    {
        int m=word1.size(),n=word2.size();
        vector<int>location(n,-1);
        for(int i=m-1,j=n-1;i>=0 && j>=0;i--)
        {
            if(word1[i]==word2[j])
               location[j--]=i;
        }
        vector<int>res;
        bool converted=false;
        for(int i=0,j=0;i<m && j<n;i++)
        {
            if(word1[i]==word2[j] || (!converted && (j==n-1 || location[j+1]>i)))
            {
                res.push_back(i);
                if(word1[i]!=word2[j])
                    converted=true;
                j++;
            }
        }
        if(res.size()<n)
           return {};
        return res;   
    }
};
```
['C++']