O(n) - cpp -  with explanation
This problem is similar to bubble sort. The core idea is, there should not be any element smaller than the i-th element in the target string and original string
This problem is similar to bubble sort. The core idea is, there should not be any element smaller than the i-th element in the target string and original string. One might ponder upon an example such as s = x0xx12xx and t = 012xxxxx. In this case, there is a smaller element 1 in between 0 and 2 however, 12  and 12 can be moved until 0s location. In order to accomodate this, we process 1 first in the target string and remove it from the list of processed items (similar to stack).\n\n\n```\nclass Solution {\npublic:\n    bool isTransformable(string s, string t) {\n        vector<vector<int>> ans(10);\n        for(int i=s.size()-1;i>=0;i--) ans[s[i]-\'0\'].push_back(i); //list of indexes in the original string for each digit added backwards\n        \n        for(int i=0;i<t.size();i++){\n            int key=t[i]-\'0\';\n            if(!ans[key].size()) return false; //check for an element in target string is present in original string\n            \n            for(int k=0;k<key;k++)\n                if(ans[k].size() && ans[k].back()<ans[key].back()) return false; //check if there are any smaller elements between the original and target string\n            ans[key].pop_back(); //remove the processed string in the above example suppose 1 is processed earlier, it gets removed and 2 can moved until the next smaller element\n        }\n            \n        return true;\n    }\n};\n```
[]