c++ binary search two pointers
\n\n# Code\n\nclass Solution {\npublic:\n    int minimumScore(string s, string t) {\n        int ans = t.length();\n        vector<int> l(t.length(), -1), r(t.l
\n\n# Code\n```\nclass Solution {\npublic:\n    int minimumScore(string s, string t) {\n        int ans = t.length();\n        vector<int> l(t.length(), -1), r(t.length(), -1);\n        int j = 0;\n        for(int i = 0;i<s.length();i++)\n        {\n            if(s[i]==t[j])\n            {\n                l[j] = i;\n                j++;\n            }\n            if(j==t.length()) break;\n        }\n         j = t.length()-1;\n         \n        for(int i = s.length()-1;i>=0;i--)\n        {\n            if(s[i]==t[j])\n            {\n                r[j] = i;\n                j--;\n            }\n            if(j<0) break;\n        }\n\n        for(int i = 0;i<t.length();i++)\n        {\n            if(l[i]!=-1) ans = min(ans,(int) t.length()-i-1);\n            if(r[i]!=-1) ans = min(ans, i);\n        }\n\n\n        for(int i = 0;i<t.length();i++)\n        {\n            if(l[i] >= r[t.length()-1]) break;\n            if(l[i]==-1) continue;\n            auto it = upper_bound(r.begin()+i+1, r.end(), l[i]) - r.begin();\n            ans = min(ans, (int)it-i-1);\n        }\n        return ans;\n        \n    }\n};\n```
['Two Pointers', 'Binary Search', 'C++']