Python Solution Using Binary Search
Code\n\nfrom bisect import bisect_right,bisect_left\nclass Solution:\n    def minimumScore(self, s: str, t: str) -> int:\n        d=[[] for _ in range(26)]\n   
# Code\n```\nfrom bisect import bisect_right,bisect_left\nclass Solution:\n    def minimumScore(self, s: str, t: str) -> int:\n        d=[[] for _ in range(26)]\n        for i in range(len(s)):\n            d[ord(s[i])-97].append(i)\n        j=len(s)\n        dp=[-1 for _ in range(len(t))]\n        for i in range(len(t)-1,-1,-1):\n            arr=d[ord(t[i])-97]\n            tem=bisect_left(arr,j)\n            if(tem==0):\n                break\n            else:\n                dp[i]=arr[tem-1]\n                j=dp[i]\n        else:\n            return 0\n        j=i\n        i=0\n        r=-1\n        ans=len(t)\n        while(i<len(t)):\n            arr=d[ord(t[i])-97]\n            tem=bisect_right(arr,r)\n            if(tem>=len(arr)):\n                ans=min(ans,j-i+1)\n                break\n            tem=arr[tem]\n            if(j+1>=len(t) or dp[j+1]>tem):\n                r=tem\n                i+=1\n            else:\n                ans=min(ans,j-i+1)\n                while(j<len(t)-1 and ( dp[j+1]<=tem)):\n                    j+=1\n                r=tem\n                i+=1\n        return ans\n\n```
['Python3']