C++ | binary search
\nclass Solution {\npublic:\n    int numMatchingSubseq(string s, vector<string>& words) {\n        int m=s.size(),n=words.size(),cnt=0;\n        vector<vector<i
```\nclass Solution {\npublic:\n    int numMatchingSubseq(string s, vector<string>& words) {\n        int m=s.size(),n=words.size(),cnt=0;\n        vector<vector<int>>pos(26);\n        for(int i=0;i<m;i++)\n            pos[s[i]-\'a\'].push_back(i);\n        bool flag;\n        for(auto &word:words)\n        {\n            int prevPosition=-1;\n            flag=true;\n            for(auto & character:word)\n            {\n                auto it=upper_bound(pos[character-\'a\'].begin(),pos[character-\'a\'].end(),prevPosition);\n                if(it==pos[character-\'a\'].end())\n                { \n                    flag=false;\n                    break;\n                }\n                else\n                    prevPosition=*it;\n            }\n            if(flag)\n                cnt++;\n        }\n        return cnt;\n    }\n};\n```\nDo UPVOTE if it helps :)\nIf you have any doubt or suggestion then please write in comment section .
['C', 'Binary Tree']