C++ | With Explanation | Prefix & Suffix
\nclass Solution {\npublic:\n    /*\n        Question can be converted into find the minimum length of substring that can be deleted such that rest becomes a su
```\nclass Solution {\npublic:\n    /*\n        Question can be converted into find the minimum length of substring that can be deleted such that rest becomes a subsequence of s\n    */\n    \n    int minimumScore(string s, string t) {\n        vector<int>prefix, suffix;\n        int i = 0, j = 0, n = s.size(), m = t.size(), count = 0;\n        while(i < n && j < m){\n            if(s[i] == t[j]){\n                i++; j++; count++;\n            }else i++;\n            prefix.push_back(count);\n        }\n        i = n - 1, j = m - 1, count = 0;\n        while(i >= 0 && j >= 0){\n            if(s[i] == t[j]){\n                i--; j--; count++;\n            }else i--;\n            suffix.push_back(count);\n        }\n        reverse(suffix.begin(), suffix.end());\n        \n        // Without taking any element\n        int maxi = suffix[0];\n        for(int i = 1 ; i < prefix.size() && i < suffix.size() ; i++){\n            // Building the biggest possible subsequence\n            maxi = max(maxi, prefix[i - 1] + suffix[i]);\n            \n            // Edge case : If we dont have to delete anything\n            if(maxi >= m)return 0;\n        }\n        \n        // Checking without taking any suffix part\n        maxi = max(prefix[prefix.size() - 1], maxi);\n        return m - maxi;\n        \n    }\n};\n\n```
['C', 'Prefix Sum']