Sharing my O( nlogn ) solution || 100% faster and memory efficient
\nclass Solution {\npublic:\n    int minimumScore(string s, string t) {\n        int n=t.size();\n        vector<int>first(n,-1),last(n,-1);\n        int i=0,j=
```\nclass Solution {\npublic:\n    int minimumScore(string s, string t) {\n        int n=t.size();\n        vector<int>first(n,-1),last(n,-1);\n        int i=0,j=0;\n        \n        \n        while(i<s.size()&&j<t.size()){\n            if(s[i]==t[j]){\n                first[j]=i;\n                i++;\n                j++;\n            }\n            else i++;\n        }\n        i=s.size()-1,j=t.size()-1;\n        while(i>=0&&j>=0){\n             if(s[i]==t[j]){\n                last[j]=i;\n                i--;\n                j--;\n            }\n            else i--;\n        }\n        if(first.back()!=-1){\n            return 0;\n        }\n        for(int i=0;i<n;i++)\n        {\n            if(first[i]==-1){\n                first[i]=s.size()+1;\n            }\n        }\n        \n        for(int i=n-2;i>=0;i--){\n            if(last[i]==-1){\n                last[i]=-1;\n            }\n        }\n        \n        \n        if(first[0]==s.size()+1){\n            return n;\n        }    \n        \n        int ans=n;\n        int l=0,r=n;\n        while(l<=r){\n            int m=(l+r)/2;\n            bool b=false;\n            for(int i=0;i<n-m-1;i++){\n                if(last[i+m+1]>first[i]){\n                    b=true;\n                    break;\n                }\n            }\n            if(b){\n                ans=m;\n                r=m-1;\n            }\n            else l=m+1;\n        }\n        for(int i=0;i<n;i++){\n            if(first[i]!=s.size()+1){\n                ans=min(ans,n-i-1);\n            }\n            if(last[i]!=-1){\n                ans=min(ans,i);\n            }\n        }\n        return ans;\n        \n    }\n};\n```
['Binary Search']