C++ solution greedy
\n// Please, upvote if you like it. Thanks :-)\nvector<int> validSequence(string word1, string word2) {\n\tint sz1 = word1.size(), sz2 = word2.size(), changed =
```\n// Please, upvote if you like it. Thanks :-)\nvector<int> validSequence(string word1, string word2) {\n\tint sz1 = word1.size(), sz2 = word2.size(), changed = 0;\n\tvector<int> first(sz2, -1), res{};\n\tfor (int i = sz1 - 1, j = sz2 - 1; i >= 0 && j >= 0; i--)\n\t\tif (j >= 0 && word1[i] == word2[j])\n\t\t\tfirst[j--] = i;\n\tfor (int i = 0, j = 0; i < sz1 && j < sz2; i++) {\n\t\tif (word1[i] == word2[j] ||\n\t\t\tchanged == 0 && (j == sz2 - 1 || i < first[j + 1]) /*next*/) {\n\t\t\tres.push_back(i);\n\t\t\tchanged += (word1[i] != word2[j++]);\n\t\t}\n\t}\n\tif (res.size() == sz2)\n\t\treturn res;\n\treturn {};\n}\n```
['Two Pointers', 'Greedy', 'C', 'C++']