💯✅🔥Easy Java ,Python3 ,C++ Solution|| 104 ms ||≧◠‿◠≦✌
java []\nclass Solution {\n    public int[] sortJumbled(int[] mapping, int[] nums) {\n        int[] mapped = new int[nums.length];\n        Map<Integer, List<In
```java []\nclass Solution {\n    public int[] sortJumbled(int[] mapping, int[] nums) {\n        int[] mapped = new int[nums.length];\n        Map<Integer, List<Integer>> map = new HashMap<>();\n        for (int i = 0; i < nums.length; i++) {\n            int number = nums[i];\n            int idx = 1;\n            int mappedNumber = 0;\n            while (number > 0) {\n                int remainder = number % 10;\n                mappedNumber = mappedNumber + (mapping[remainder] * idx);\n                number = number / 10;\n                idx *= 10;\n            }\n            if (nums[i] == 0) {\n                mappedNumber = mapping[0];\n            }\n            mapped[i] = mappedNumber;\n            if (!map.containsKey(mapped[i])) {\n                map.put(mapped[i], new ArrayList<>());\n            }\n            map.get(mapped[i]).add(nums[i]);\n        }\n        Arrays.sort(mapped);\n        int idx = 0;\n        for (int i = 0; i < mapped.length; i++) {\n            if (map.containsKey(mapped[i])) {\n                for (int val : map.get(mapped[i])) {\n                    nums[idx] = val;\n                    idx++;\n                }\n            }\n            map.remove(mapped[i]);\n        }\n        return nums;\n    }\n}\n```\n```python3 []\nclass Solution:\n    def sortJumbled(self, mapping: List[int], nums: List[int]) -> List[int]:\n        mapped = [0] * len(nums)\n        num_map = defaultdict(list)\n        \n        for i in range(len(nums)):\n            number = nums[i]\n            idx = 1\n            mapped_number = 0\n            \n            while number > 0:\n                remainder = number % 10\n                mapped_number += mapping[remainder] * idx\n                number //= 10\n                idx *= 10\n            \n            if nums[i] == 0:\n                mapped_number = mapping[0]\n            \n            mapped[i] = mapped_number\n            num_map[mapped[i]].append(nums[i])\n        \n        sorted_mapped = sorted(mapped)\n        idx = 0\n        \n        for value in sorted_mapped:\n            if value in num_map:\n                for val in num_map[value]:\n                    nums[idx] = val\n                    idx += 1\n                del num_map[value]\n        \n        return nums\n```\n```C++ []\nclass Solution {\npublic:\n    vector<int> sortJumbled(vector<int>& mapping, vector<int>& nums) {\n        vector<int> mapped(nums.size());\n        unordered_map<int, list<int>> num_map;\n        \n        for (int i = 0; i < nums.size(); i++) {\n            int number = nums[i];\n            int idx = 1;\n            int mapped_number = 0;\n            \n            while (number > 0) {\n                int remainder = number % 10;\n                mapped_number += mapping[remainder] * idx;\n                number /= 10;\n                idx *= 10;\n            }\n            \n            if (nums[i] == 0) {\n                mapped_number = mapping[0];\n            }\n            \n            mapped[i] = mapped_number;\n            num_map[mapped[i]].push_back(nums[i]);\n        }\n        \n        vector<int> sorted_mapped = mapped;\n        sort(sorted_mapped.begin(), sorted_mapped.end());\n        int idx = 0;\n        \n        for (int value : sorted_mapped) {\n            if (num_map.find(value) != num_map.end()) {\n                for (int val : num_map[value]) {\n                    nums[idx++] = val;\n                }\n                num_map.erase(value);\n            }\n        }\n        \n        return nums;\n    }\n};\n```\n---\n![upvote.png](https://assets.leetcode.com/users/images/ca37c7f6-996c-424e-ae36-34378f49fe75_1721612926.752737.png)\n\n---\n\n
['Array', 'Sorting', 'C++', 'Python3']