C++ solution with explanation
Basic Approach: \n-\nStep 1. Storing indices of alphabets in given string using a 2D vector. The values in each array will be in sorted manner.\nStep 2. Travers
**Basic Approach:** \n-\n**Step 1.** Storing indices of alphabets in given string using a 2D vector. The values in each array will be in sorted manner.\n**Step 2.** Traversing over the vector **"words"** and iterating over each element, and checking whether word is present as a sequence in the given string. In the process of traversing, we will keep track of the previous index where the match was made.\n<br/>\n<h3>Let\'s understand with the help of an example</h3>\n\n* Let **s = "abcde"** and **words = [["a","bb","acd"]]**.\n* We will iterate over s, and store indices of occurrence of an alphabet in corresponding row of a 2d vector.\n* After iteration, 2d vector rows will be as follows:\n\n\t\trow 0: [0]     // storing indices of \'a\'\n\t\trow 1: [1]     // storing indices of \'b\'\n        row 2: [2]     // storing indices of \'c\'\n        row 2: [3]     // storing indices of \'d\'\n        row 2: [4]     // storing indices of \'e\'\n\n* Now we will iterate over given vector of strings **words**.\n\t- ***For words[0], i.e. "a":*** Initial value of **ind** will be -1. We will look at the least value out of all the possible value of indices (present in the 0th row of 2d vector), which will be greater than the value of ind. This will ensure that we move in sequence. We find the value at 0th index of 0th row. Since it is a valid index, we will check further after assigning 0 to the ind. Since word is present, we increment the **res** storing count of found words.\n\n\t- ***For words[1], i.e. "bb":*** Value of ind will be -1 initially. We will check 1st row of 2d vector to find smallest index greater than the value of ind. We find the element 1, at 0th column, and since 0 is valid index, we will assign 1 to ind, and check further. 2nd alphabet is \'b\' again, so we will check the 1st row again for the smallest value greater than ind, i.e. 1. We get the index 1 but since size of 1st row is 1, so max possible index would be 0., and thus, it would not be a vlid index. Thus we will break out and check for other words.\n\n\t- ***For words[2], i.e. "acd"*** Initial value of ind = -1. We check 0th row to find smallest index greater than value of ind. We find 0 at 0th row. Since it is valid, we assign 0 to ind, and check further. For \'c\', we check 2nd row, and find 2 at 0th index. Since 0 is a valid index, we assign 2 to ind, and check further. We check 3rd row for \'d\' and find 4 at 0th index. Since it is again valid index, we assign value 4 to ind. But since word has been traversed and sequence was found, we will increment the result.\n\n\n**Code:**\n-\n```\nclass Solution {\npublic:\n    int res = 0;\n    \n    int numMatchingSubseq(string s, vector<string>& words) {\n        vector<vector<int>> map(26, vector<int>());\n        for(int i = 0 ; i < s.size() ; ++i)\n            map[s[i] - \'a\'].push_back(i);\n        \n        for(auto& word : words) {\n            int ind = -1;\n            for(int i = 0 ; i < word.size() ; ++i) {\n                vector<int>& v = map[word[i] - \'a\'];\n                int tempInd = lower_bound(v.begin(), v.end(), ind + 1) - v.begin();\n                if(tempInd >= v.size()) {\n                    ind = -1;\n                    break;\n                }\n                \n                ind = v[tempInd];\n            }\n            if(ind != -1)\n                ++res;\n        }\n        return res;\n    }\n};\n```
['Binary Tree', 'C++']