[Java] O(n)
Intuition:\n Loop from the last digit and move towards the first one. We can move digits to the right - because we can sort substrings in ascending order.\n To 
Intuition:\n* Loop from the last digit and move towards the first one. We can move digits to the right - because we can sort substrings in ascending order.\n* To move a digit to the right you can just sort two digits: "**51**23" -> "**15**23" -> "1**52**3" -> "1**25**3" -> "12**53**" -> "123**5**"\n* We can move a digit A to the right, if all digits on the way are less than the digit A.\n  * Ex: "**5**123", we can move "**5**" to any position to the right, since all digits on the way are less that "**5**"\n  * Ex: "**5**7", we can NOT move "**5**", since there is "7" to the right\n```\npublic boolean isTransformable(String s, String t) {\n\t// positions of all digits\n\tStack<Integer>[] pos = new Stack[10];\n\tfor (int i = 0; i < 10; i++) {\n\t\tpos[i] = new Stack<>();\n\t}\n\tfor (int i = 0; i < s.length(); i++) {\n\t\tpos[s.charAt(i) - \'0\'].push(i);\n\t}\n\n\tfor (int i = s.length() - 1; i >= 0; i--) {\n\t\tint targetDigit = t.charAt(i) - \'0\';\n\t\tif (pos[targetDigit].size() == 0) {\n\t\t\treturn false;\n\t\t}\n\t\tint targetDigitIndexInS = pos[targetDigit].pop();\n\t\t// check that there are no bigger digits on the way \n\t\tfor (int j = targetDigit + 1; j < pos.length; j++) {\n\t\t\tif (pos[j].size() > 0 && pos[j].peek() > targetDigitIndexInS) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn true;\n}\n```
[]