Easy to understand C++ O(N) code
\nclass Solution {\npublic:\n    int minimumScore(string s, string t) {\n        vector<int> left, right;\n        int idx = 0; int n = t.size();\n        \n   
```\nclass Solution {\npublic:\n    int minimumScore(string s, string t) {\n        vector<int> left, right;\n        int idx = 0; int n = t.size();\n        \n        // Scan for left to right get the maxiumm matches\n        for (int i = 0; (i < s.size()) && (idx < n); i++) {\n            if (s[i] == t[idx]) {\n                left.push_back(i);\n                idx++;\n            }\n        }\n        // initial result will be unmatached characters from the left\n        int result = n-left.size();\n        idx = n-1;\n        \n        // try matching characters from right to left\n        for (int i = s.size()-1; (i >= 0) && (idx >= 0) && (result != 0); i--) {\n            if (s[i] == t[idx]) {\n                // in order to push to right, left wipe out the matches from left part\n                // greater than equal to current index\n                while (left.size() && (left.back() >= i)) {\n                    // if moving from right to left we found this character earlier\n                    // then we pop from left and let right proceed further \n                    left.pop_back();\n                }\n                right.push_back(i);\n                // compute the current state of the unmatched character \n                int cur = (n - (left.size() + right.size()));\n                result = min(result,cur);\n                idx--;\n            }\n        }\n        \n        return result;\n    }\n};\n```
[]