C++ || EASY || BINARY SEARCH + PREFIX SUM || BEATS 100%
\n\n# Code\n\nclass Solution {\npublic:\n    int minimumScore(string s, string t) {\n        int n = s.size();\n        int m = t.size();\n\n        vector<int>
\n\n# Code\n```\nclass Solution {\npublic:\n    int minimumScore(string s, string t) {\n        int n = s.size();\n        int m = t.size();\n\n        vector<int>pref(m, n);\n        vector<int>suff(m, -1);\n\n        int p = 0, i = 0;\n        while(p < m && i < n) {\n            if(t[p] == s[i]) {\n                pref[p] = i;\n                p++; i++;\n            }else {\n                i++;\n            }\n        }\n        // for(int i=0; i<pref.size(); i++) {\n        //     cout << pref[i];\n        // }\n        int su = m-1, j = n-1;\n        while(su >= 0 && j >= 0) {\n            if(t[su] == s[j]) {\n                suff[su] = j;\n                su--; j--;\n            }else {\n                j--;\n            }\n        }\n        int mini = INT_MAX;\n\n        for(int left = 0; left<m; left++) {\n            int pos = (left > 0) ? pref[left-1] : -1;\n            if(pos == n) break;\n\n            int right = upper_bound(suff.begin(), suff.end(), pos) - suff.begin();\n\n            if(left <= right) mini = min(mini, right-left);\n        }\n        return mini;\n    }\n};\n```
['C++']