two pass String s, greedy
Intuition\n Describe your first thoughts on how to solve this problem. \nfor every letter in s, we can either use it to match prefix or suffix in t.\n\n(No need
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nfor every letter in s, we can either use it to match prefix or suffix in t.\n\n(No need to worry about overlap of prefix and suffix in t, as long as every letter in s match either prefix or suffix, that won\'t cause problem)\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1.go left to right in s , try match as many prefix of t as we can, for every character in s, \nwe mark if it is used to match t prefix. \n\nWhat left in t is need to be remove.\n\n2.then go right to left in s, if a letter is used for prefix , now we no longer can use it for prefix becasue we are building suffix now, so we delete one character in prefix which means we need to increase the letter we remove(cur++). \nif it match t suffix, we add one more letter to suffix and we decrase the letter we remove.\n\n# Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public int minimumScore(String s, String t) {\n        boolean[] record = new boolean[s.length()];\n        int ti = 0;\n        for (int i = 0; i < s.length() && ti < t.length(); i++) {\n            if (s.charAt(i) == t.charAt(ti)) {\n                record[i] = true;\n                ti++;\n            }\n        }\n        int ans = t.length() - ti;\n        if (ti == t.length()) return ans;\n        int cur = ans;\n        ti = t.length() - 1;\n        for (int i = s.length() - 1; i >= 0 && ti >= 0; i--) {\n            if (record[i]) cur++;\n            if (s.charAt(i) == t.charAt(ti)) {\n                cur--;\n                ti--;\n            }\n            ans = Math.min(ans, cur);\n        }\n        return ans;\n    }\n}\n```
['Java']