Java Simple O(N)
Reference: @votrubac\ntrue if:\nevery smaller digit\'s position in t is not earlier than that in s.\nBecause you can only move smaller digit in s to the front b
[Reference](https://leetcode.com/problems/check-if-string-is-transformable-with-substring-sort-operations/discuss/843917/C%2B%2BJavaPython-O(n)): @votrubac\ntrue if:\nevery smaller digit\'s position in t is not earlier than that in s.\nBecause you can only move smaller digit in s to the front by passing larger digits.\n```\n    public boolean isTransformable(String s, String t) {\n        Map<Integer, List<Integer>> map = new HashMap<>();\n        int[] cnt = new int[10];\n        for (int i = 0; i < 10; i++) map.put(i, new ArrayList<>());\n        for (int i = 0; i < s.length(); i++) map.get(s.charAt(i) - \'0\').add(i);\n        for (int i = 0; i < t.length(); i++){\n            int d = t.charAt(i) - \'0\';\n            if (cnt[d] >= map.get(d).size()) return false;  // not equal count of digits\n            int dpos = map.get(d).get(cnt[d]);  //position of d to move in s;\n            for (int j = 0; j < d; j++) //looping all prev smaller digit, make sure not moving smaller digit after dpos;\n                if (cnt[j] < map.get(j).size() && map.get(j).get(cnt[j]) < dpos) return false;\n            cnt[d]++;\n        }\n        return true;\n    }\n```\n
[]