C++ | Greedy | O(N) Solution | Cleanest Code
\nclass Solution {\npublic:\n    bool isTransformable(string s, string t) {\n        //we have to return just true or false\n        //Codeforces D\n       \n  
```\nclass Solution {\npublic:\n    bool isTransformable(string s, string t) {\n        //we have to return just true or false\n        //Codeforces D\n       \n        //so we basically first stored the positions of each digit in s and t,digits ranging from 0 till 9\n        vector<deque<int>> v(10);\n        for(int i=0;i<s.size();i++){\n            v[s[i]-\'0\'].push_back(i);\n        }\n        for(int i=0;i<t.size();i++){\n            int num=t[i]-\'0\';\n            //first look whether this number is available in the string s\n            if(v[num].empty()){\n                //if this number is not in s itself return false\n                return false;\n            }\n            //now check all the digits which are less than this current num\n            //check if any of such digits appear before this current num\'s front\n            //if so,then this digit will be smaller than num and hence will block the pathway of num,so return false\n            for(int dig=0;dig<num;dig++){\n                if(v[dig].empty()==false and v[dig].front()<v[num].front()){\n                    return false;\n                }\n            }\n            v[num].pop_front();//after placing num at the target[i] pos,pop it out\n        }\n        return true;\n        \n    }\n};\n```
[]