Java with Comments - O(n)
\n/*\n    Time Complexity: O(n)\n    Space Complexity: O(n)\n*/\nclass Solution {\n    public boolean isTransformable(String s, String t) {\n        List<Intege
```\n/*\n    Time Complexity: O(n)\n    Space Complexity: O(n)\n*/\nclass Solution {\n    public boolean isTransformable(String s, String t) {\n        List<Integer> []a = new ArrayList[10];\n        for(int i=0;i<10;i++){\n            a[i] = new ArrayList();\n        }\n        //store positions of all characters\n        for(int i=0;i<s.length();i++){\n            a[s.charAt(i) - \'0\'].add(i);\n        }\n        //first position of each character in list \'a\' that has not been used for String \'t\'\n        int []pos = new int[10];\n        for(int i=0;i<t.length();i++){\n            int val = t.charAt(i) - \'0\';\n            if(a[val].size() <= pos[val]){  //no more occurrence of \'val\' character available\n                return false;\n            }\n            for(int j=0;j<val;j++){     //for every character less than \'val\' \n                if(a[j].size() > pos[j]     //there exists more occurrence of character \'j\'\n                   && a[j].get(pos[j]) < a[val].get(pos[val])){     //character \'j\' comes before \'val\' in String \'s\'\n                    return false;\n                }\n            }\n            pos[val] ++;    //character \'val\' at pos[val] in list \'a\' is used for position \'i\' in String \'t\'\n        }\n        return true;\n    }\n}\n```
[]