🚀🔢 Sort Jumbled Numbers Using Custom Mapping 🔢🚀 | 💾 Space Complexity:  𝑂(1)
Intuition\n Describe your first thoughts on how to solve this problem. \nThe goal is to sort an array of numbers based on a custom digit mapping. For each numbe
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe goal is to sort an array of numbers based on a custom digit mapping. For each number in the array, we need to transform it according to the mapping and then sort the array based on the transformed values. If two transformed values are the same, the original numbers should maintain their relative order (stable sorting).\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n- Transform Each Number: For each number in the input array, transform it using the given digit mapping. This transformation involves replacing each digit of the number with its corresponding mapped digit.\n- Sort the Array: Use a custom comparator to sort the array. The comparator will compare the transformed values of the numbers. If the transformed values are equal, the comparator will ensure the original order of the numbers is maintained (stable sorting).\n\n# Complexity\n- Time complexity: O(nlogn)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int getNumber(int num, vector<int> &mapping) {\n        if (num == 0) return mapping[0];\n\n        int opt = 0;\n        int factor = 1;\n\n        while (num) {\n            opt += mapping[num % 10] * factor;\n            factor *= 10;\n            num /= 10;\n        }\n\n        return opt;\n    }\n\n    vector<int> sortJumbled(vector<int>& mapping, vector<int>& nums) {\n        int n = nums.size();\n        sort(nums.begin(), nums.end(), [&](int a, int b) {\n            int mapped_a = getNumber(a, mapping);\n            int mapped_b = getNumber(b, mapping);\n            if (mapped_a == mapped_b)\n                return false;\n            return mapped_a < mapped_b;\n        });\n        return nums;\n    }\n};\n```
['Array', 'Hash Table', 'Sorting', 'C++']