C++ 128ms, O(n)
This is @kmjp\'s solution, idea behind this is, you can place a digit(t[i]) at i iff there isn\'t any smaller unused digit having lower index than t[i] in strin
This is @kmjp\'s solution, idea behind this is, you can place a digit(t[i]) at i iff there isn\'t any smaller unused digit having lower index than t[i] in string s.\n```\nclass Solution {\npublic:\n    bool isTransformable(string s, string t) {\n        int n=s.size();\n        queue<int>q[10];   //indexes of every digit \n        for(int i=0;i<n;i++)q[s[i]-\'0\'].push(i);\n        for(int j=0;j<n;j++)\n        {\n            int k=t[j]-\'0\';\n            if(q[k].empty())return 0;\n            for(int i=0;i<k;i++)if(q[i].size() and q[i].front()<q[k].front())return 0;   //if smaller digit has lower index it will come first hence the arrangement isn\'t possible\n            q[k].pop();\n        }\n        return 1;\n    }\n};\n```\nTime: O(n)\nSpace: O(n)
['Queue']