Detailed explanation with better comments
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\nO(S.length() + T.length())\n\n- Space complexity:\nO(S.length())\n\n# Code\n```\nclass Solution {\n    public boolean isTransformable(String s, String t) {\n        Map<Integer, List<Integer>> mapToStoreStringSDigitIndex = new HashMap<Integer, List<Integer>>();\n\n        for (int index = 0; index < 10; index++) {\n            mapToStoreStringSDigitIndex.put(index, new ArrayList<Integer>());\n        }\n\n        for (int index = 0; index < s.length(); index++) {\n            int currDigit = s.charAt(index) - \'0\';\n            mapToStoreStringSDigitIndex.get(currDigit).add(index);\n        }\n\n        int[] digitCountInStringTEncounteredSoFar = new int[10];\n\n        for (int index = 0; index < t.length(); index++) {\n            int currDigit = t.charAt(index) - \'0\';\n            // checking for anagram here. S and T should have equal number of x digit.\n            // S = 2341, T = 2231 => Invalid anagram\n            // S = 2431, T = 4123 => Valid anagram\n            if (digitCountInStringTEncounteredSoFar[currDigit] >= mapToStoreStringSDigitIndex.get(currDigit).size()) {\n                return false;\n            }\n\n            // Access the curr digit position from string S, we might have x digit with multiple occurance. To store this we use \n            // "digitCountInStringTEncounteredSoFar" array.\n            int currDigitPositionInStringS = mapToStoreStringSDigitIndex.get(currDigit).get(digitCountInStringTEncounteredSoFar[currDigit]);\n\n            // Here we check whether we have a digit smaller than "currDigit" before the "currDigit".\n            // S = 84523, T = 34852\n            // We can\'t move digit 3 in String S to 0th index, because we have 2 before 3. If we sort we get 23 in the sequence.\n            for (int digit = 0; digit < currDigit; digit++) {\n                if (digitCountInStringTEncounteredSoFar[digit] < mapToStoreStringSDigitIndex.get(digit).size() &&\n                    mapToStoreStringSDigitIndex.get(digit).get(digitCountInStringTEncounteredSoFar[digit]) < currDigitPositionInStringS) {\n                    return false;\n                }\n            }\n\n            digitCountInStringTEncounteredSoFar[currDigit]++;\n        }\n\n        return true;\n    }\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n```
['Java']