2 scans for prefix/suffix, O(n).
We need to find a combination of a prefix/suffix subsequence that has the longest combined length.  First scan left-to-right finding the offsets into s for ever
We need to find a combination of a prefix/suffix subsequence that has the longest combined length.  First scan left-to-right finding the offsets into s for every character in t that can be a part of a subsequence.  Then do the same scanning right-to-left and matching with the longest subsequence that ends before the current position.\n```\nint minimumScore(string s, string t) {\n    int n=s.size();\n    int l=0;   // index of char in t in a prefix subsequence.\n    vector<int> pref(t.size()+1, 100001);\n    pref[0]=-1;\n    for (int pos=0; l<t.size(); l++, pos++) {\n        while (pos<n && s[pos]!=t[l]) ++pos;\n        if (pos==n) break;\n        pref[l+1]=pos;         \n    }\n    if (l==t.size()) return 0;   // full string is a subsequence!\n    int ans=t.size()-l;\n    for (int i=t.size()-1, pos=s.size()-1; i>=0; i--, pos--) {\n        while (pos>=0 && s[pos]!=t[i]) --pos;\n        if (pos<0) break;\n        while (l>=0 && (l>=i || pref[l]>=pos)) --l;\n        ans=min(ans, i-l); \n    }\n    return ans;     \n}\n```
['C++']