[C++] binary search beat 99%
\nclass Solution {\npublic:\n    int numMatchingSubseq(string s, vector<string>& words) {\n        int res=0;\n        vector<vector<int>>A(26);\n        for(in
```\nclass Solution {\npublic:\n    int numMatchingSubseq(string s, vector<string>& words) {\n        int res=0;\n        vector<vector<int>>A(26);\n        for(int i=0;i<s.size();i++){\n            A[s[i]-\'a\'].push_back(i);\n        }\n        \n        for(string &w:words){\n            int pre=-1;\n            bool flag=true;\n            for(int i=0;i<w.size();i++){\n                vector<int>&v=A[w[i]-\'a\'];\n                int pos=-1;\n                int l=0,r=v.size()-1;\n                while(l<=r){\n                    int mid=l+(r-l)/2;\n                    if(v[mid]>pre){\n                        pos=mid;\n                        r=mid-1;\n                    }else{\n                        l=mid+1;\n                    }\n                }\n                if(pos==-1){\n                    flag=false;\n\t\t\t\t\tbreak;\n                }else{\n                    pre=v[pos];\n                }\n            }\n            if(flag)res++;\n        }\n        \n        return res;\n    }\n};\n```
[]