1700+ ms | Sorting Custom Comparator | What have i done 💀|
Approach\nWe first convert each number to a string \uD83D\uDC80 and map each digit to its corresponding value from the mapping vector \uD83D\uDC80. We define a 
# Approach\nWe first convert each number to a string \uD83D\uDC80 and map each digit to its corresponding value from the mapping vector \uD83D\uDC80. We define a helper function mapStringToInt to perform this conversion and use it within a custom comparator in the C++ sort function. This custom comparator ensures that the numbers are sorted according to their mapped integer values.\n\n# Complexity\n- Time complexity:\n O(n log n d)\n N -> is the number of elements in the nums array.\n D -> is the average number of digits in the numbers.\n\n- Space complexity:\n O(log n)\n\n# Code\n```\nclass Solution {\nprivate:\n    long long mapStringToInt(string num, vector<int> &mapping){\n        long long res = 0;\n\n        for(int i = 0; i < num.size(); i++){\n            int idx = num[i] - \'0\';\n            res = (res + mapping[idx]) * 10;\n        }\n        \n        res = res / 10;\n\n        return res;\n    }\npublic:\n    vector<int> sortJumbled(vector<int>& mapping, vector<int>& nums) {\n        \n        auto lambda = [&](auto first, auto second){\n            return mapStringToInt(to_string(first), mapping) < mapStringToInt(to_string(second), mapping);\n        };\n\n        sort(nums.begin(), nums.end(), lambda);\n\n        return nums;\n    }\n};\n```
['C++']