[Java] Clean greedy + binary search solution
Intuition\n\nDon\'t be confused by the "subsequence". Here the score is defined as right - left + 1, meaning that all chars between left and right can be remove
# Intuition\n\nDon\'t be confused by the "subsequence". Here the score is defined as `right - left + 1`, meaning that all chars between `left` and `right` can be removed all together. Or, we can say - removing part of them doesn\'t change anything.\n\nThen we can greedily check for prefix and suffix of t to get the max of `left` and min of `right`. We also need to make sure there is no overlap on s, binary search can help here.\n\n# Code\n```\nclass Solution {\n    public int minimumScore(String s, String t) {\n        int leftT = 0;\n        List<Integer> leftSs = new ArrayList<>();\n\n        for (int i = 0; i < s.length() && leftT < t.length(); i++) {\n            if (s.charAt(i) == t.charAt(leftT)) {\n                leftSs.add(i);\n                leftT++;\n            }\n        }\n\n        int rightT = t.length() - 1;\n        List<Integer> rightSs = new ArrayList<>();\n        for (int i = s.length() - 1; i >= 0 && rightT >= 0; i--) {\n            if (s.charAt(i) == t.charAt(rightT)) {\n                rightSs.add(i);\n                rightT--;\n            }\n        }\n\n        int result = Math.min(t.length() - leftT, rightT + 1);\n        for (int i = 0; i < rightSs.size(); i++) {\n            int ind = rightSs.get(i) - 1;\n            int left = Collections.binarySearch(leftSs, ind);\n            if (left < 0) {\n                left = ~left;\n            } else {\n                left++;\n            }\n            result = Math.min(result, Math.max(0, t.length() - i - 1 - left));\n            if (result == 0) {\n                break;\n            }\n        }\n\n        return result;\n    }\n}\n```
['Java']