Java O(n) with recording the count of less number.
\nclass Solution {\n    public boolean isTransformable(String s, String t) {\n        List<Integer>[] idx = new ArrayList[10];\n        for (int i = 0; i < 10; 
```\nclass Solution {\n    public boolean isTransformable(String s, String t) {\n        List<Integer>[] idx = new ArrayList[10];\n        for (int i = 0; i < 10; i++) {\n            idx[i] = new ArrayList<>();\n        }\n        int n = s.length();\n        int[] ct = new int[10];\n        for (int i = 0; i < n; i++) {\n            int d = t.charAt(i) - \'0\';\n            ct[d]++;\n            idx[d].add(less(ct, d));\n        }\n        \n        int[] cnt = new int[10];\n        for (int i = 0; i < n; i++) {\n            int d = s.charAt(i) - \'0\';\n            if (cnt[d] >= idx[d].size()) return false;\n            if (idx[d].get(cnt[d]) < less(cnt, d)) return false;\n            cnt[d]++;\n        }\n        \n        return true;\n    }\n    int less(int[] cnt, int i) {\n        int res = 0;\n        for (int j = 0; j < i; j++) {\n            res += cnt[j];\n        }\n        return res;\n    }\n}\n```
[]