Python | Iterate from both sides | Explanation and Comment
First, we consider that given left that t[:left] is a substring of s[:sleft], how can we find the best right?\nOf course, right should be as small as possible. 
First, we consider that given `left` that `t[:left]` is a substring of `s[:sleft]`, how can we find the best `right`?\nOf course, `right` should be as small as possible. Even we delete a ton of character inside `t` but `t[len(t)-1]` is not deleted, the score is still `len(t) - left`.\nThus, we should start with the last character of `t` to find if there\'s a character equals to it in `s[sleft:]`. Every time we find, we should choose the rightest index and we can decrease `right`. Until we cannot decrease `right`, then we should decrease `left` by one to make `sleft` smaller for giving more characters for `t[right]` to match.\n\n\n# Code\n```Python[]\nclass Solution:\n    def minimumScore(self, s: str, t: str) -> int:\n        sl = 0\n        sr = len(s) - 1\n        tl = 0\n        tr = len(t) - 1\n        k = {}\n        for tl in range(len(t)):\n            while sl < len(s) and s[sl] != t[tl]:\n                sl += 1\n            if sl == len(s):\n                tl -= 1\n                break\n            # save smallest sleft for all left\n            k[tl] = sl\n            sl += 1\n            \n        # we set left = -1, when we don\'t use left\n        k[-1] = -1\n        ans = tr - tl\n        # iterate every left by decreasing one\n        # releave the limitation of s[sleft:]\n        for ntl in range(tl, -2, -1):\n            # every time we decrease left, check if right can be decreased\n            while tr > ntl and sr > k[ntl]:\n                if s[sr] != t[tr]:\n                    sr -= 1\n                elif s[sr] == t[tr]:\n                    sr -= 1\n                    tr -= 1\n            ans = min(tr - ntl, ans)\n        return ans\n```
['Python', 'Python3']