Python O(n) solution with clear logical coding
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution:\n    def minimumScore(self, s: str, t: str) -> int:\n\n        # 1. build prefix and suffix\n        #   prefix[i]: index of t which has its left part a subsequence of s[:i]\n        #              t[: prefix[i]] is a subsequence of s[: i]\n        #   suffix[i]: index of t which has its right part a subsequence of s[i:]\n        #               t[suffix[i] :] is a subsequence of s[i :]\n        #   prefix is left-to-right scanning, while suffix is right-to-left scanning\n        \n        prefix = [-1] * len(s)\n        i = j = 0\n        while i < len(s):\n            if j < len(t) and s[i] == t[j]:\n                prefix[i] = j\n                j += 1\n            elif i > 0:\n                prefix[i] = prefix[i - 1]\n            i += 1\n\n        if prefix[-1] == len(t) - 1:    # t is subsequence of s\n            return 0\n\n        suffix = [len(t)] * len(s)\n        i, j = len(s) - 1, len(t) - 1\n        while i >= 0:\n            if j >= 0 and s[i] == t[j]:\n                suffix[i] = j\n                j -= 1\n            elif i < len(s) - 1:\n                suffix[i] = suffix[i + 1]\n            i -= 1\n\n        # 2. scan s to find the longest subsequence based on prefix and suffix\n        # since t is not a subsequence of s, so prefix[i] < suffix[i]\n\n        length = float(\'Inf\')\n\n        for idx in range(len(s)):\n            # check if s[idx] is the first match for s[prefix[idx]] and s[suffix[idx]]\n            # if so, need to remove one more chars\n            if (prefix[idx] >= 0) and (idx == 0 or prefix[idx] > prefix[idx - 1]):\n                pre_match = True    # s[idx] is the one to match t[prefix[idx]] for the first time\n            else:\n                pre_match = False\n            if (suffix[idx] < len(t)) and (idx == len(s) - 1 or suffix[idx] < suffix[idx + 1]):\n                suf_match = True    # s[idx] is the one to match t[suffix[idx]] for the first time\n            else:\n                suf_match = False\n\n            if  pre_match and suf_match:\n                length = min(length, suffix[idx] - prefix[idx])\n            else:\n                length = min(length, suffix[idx] - prefix[idx] - 1)\n\n        return length\n        \n        \n        \n        \n        \n        \n        \n```
['Python3']