Java Brute Force Solution
Intuition\n Describe your first thoughts on how to solve this problem. \nGiven a mapping of digits, the goal is to transform each number in an array according t
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nGiven a mapping of digits, the goal is to transform each number in an array according to this mapping, then sort the array based on these transformed values.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nMapping the Digits: For each number in the input array, create a mapped value using the provided digit mapping.\nPairing Original and Mapped Values: Store both the original and the mapped value in a 2D array.\nSorting: Sort the 2D array based on the mapped values.\nReconstructing the Result: Extract the original numbers from the sorted 2D array and return them as the result.\n\n# Complexity\n- Time complexity: O(nlogn)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public int[] sortJumbled(int[] mapping, int[] nums) {\n        int n = nums.length;\n        int map[][] = new int[n][2];\n        for(int i=0; i<n; i++){\n            int d = nums[i];\n            map[i][0] = d;\n            map[i][1] = getMappedValue(mapping, d);\n        }\n        Arrays.sort(map, (a, b) -> Integer.compare(a[1], b[1]));\n        for (int i = 0; i < n; i++) {\n            nums[i] = map[i][0];\n        }\n        return nums;\n    }\n    private int getMappedValue(int[] mapping, int num) {\n        if (num == 0) {\n            return mapping[0];\n        }\n        int mappedValue = 0;\n        int place = 1;\n        while (num > 0) {\n            int digit = num % 10;\n            mappedValue += mapping[digit] * place;\n            num /= 10;\n            place *= 10;\n        }\n        return mappedValue;\n    }\n}\n```
['Java']