C++ || prefix & suffix || O(n)
Code\n\nclass Solution {\npublic:\n    int minimumScore(string s, string t) {\n        int n = s.size();\n        int m = t.size();\n        vector<int> f(n,0),
# Code\n```\nclass Solution {\npublic:\n    int minimumScore(string s, string t) {\n        int n = s.size();\n        int m = t.size();\n        vector<int> f(n,0),b(n,0);\n        int j=0;\n        for(int i=0;i<n;i++){\n            if(j<m && s[i] == t[j]){\n                j++;\n            }\n            f[i]=j;\n        }\n        j=m-1;\n        for(int i=n-1;i>=0;i--){\n            if(j>=0 && s[i] == t[j]){\n                j--;\n            }\n            b[i]=m-j-1;\n        }\n        int ans = min(m-f[n-1],m-b[0]);\n        for(int i=1;i<n;i++){\n            ans = min(ans,m-f[i-1]-b[i]);\n        }\n        return max(ans,0);\n    }\n};\n```
['Suffix Array', 'Prefix Sum', 'C++']