c++ small 
IntuitionFind the last possible position where word1[i] can match word2[j].
If we miss word1[i] when i = last[j], we won't be able to form an almost equal strin
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
Find the last possible position where word1[i] can match word2[j].
If we miss word1[i] when i = last[j], we won't be able to form an almost equal string.

Iterate through each character in word1.

If it matches word2[j], we greedily include it.

If it doesn't match, we try to skip word2[j] by checking if i < last[j + 1].

These two cases help ensure the result is as small as possible.

Finally, return the result if we successfully find the almost equal string.
# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

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