C++ | O(N) Time | O(N) Space | 10 pointers | Optimal Swapping
\nclass Solution {\npublic:\n    vector<vector<int>> pLoc;\n    vector<int> ptr;\n    \n    bool isPossible(string& s, int num){\n        for(int i=0;i<num;i++)
```\nclass Solution {\npublic:\n    vector<vector<int>> pLoc;\n    vector<int> ptr;\n    \n    bool isPossible(string& s, int num){\n        for(int i=0;i<num;i++){\n            if(ptr[i]==-1) continue;\n            if(ptr[i]>=pLoc[i].size()) continue;\n            if(pLoc[i][ptr[i]]<pLoc[num][ptr[num]]) return false;\n        }\n        return true;\n    }\n    bool isTransformable(string s, string t) {\n        pLoc.resize(10);\n        ptr.resize(10,-1);\n        \n        for(int i=0;i<s.length();i++) {\n            ptr[s[i]-\'0\']=0;\n            pLoc[s[i]-\'0\'].push_back(i);\n        }\n        \n        for(int i=0;i<t.length();i++){\n            int num = t[i]-\'0\';\n            if(ptr[num]==-1) return false;\n            if(isPossible(s,num)) ptr[num]++;\n            else return false;\n        }\n        return true;\n    }\n};\n```
['String', 'Greedy']