Efficient Mapping and Custom Sorting, Simple Solution
Intuition\nIf we map all the indices with their corrosponding values, we can form a number and when we sort those numbers We will end up with the exact order th
# Intuition\nIf we map all the indices with their corrosponding values, we can form a number and when we sort those numbers We will end up with the exact order that has been asked in the problem\n\n# Approach\n1) Map all the indices with the element present at that index\n\n2) We will convert the numbers into strings just for simplicity of operations, you can not iterate through numbers but you can easily iterate through strings\n\n3) Then for those converted strings, we will pair them with their corrosponding number.\n\n4) Convert the paires Strings into integers again because we have to compare Intergers values.\n\n5) Use Custom sort based on what the problem is asking, and simply collect all the integers in the order after sorting is done\n\n# Complexity\n- Time complexity:\n*O(n log n)* Since Sorting is involved.\n\n- Space complexity:\n*O(n)* We only have taken linear data structures to store our numbers and strings\n\n# Code\n```\n#include <bits/stdc++.h>\nusing namespace std;\n#define nline \'\\n\'\n#define sp \' \'\n#define all(x) x.begin(), x.end()\n#define rall(x) x.rbegin(), x.rend()\nstatic int fastIO = []\n{\n    ios_base::sync_with_stdio(false);\n    cin.tie(0);\n    cout.tie(0);\n    return 0;\n}();\n\nclass Solution\n{\nprivate:\n    static bool comp(pair<int, int> &a, pair<int, int> &b)\n    {\n        return a.first < b.first;\n    }\n\npublic:\n    vector<int> sortJumbled(vector<int> &mapping, vector<int> &nums)\n    {\n        unordered_map<int, int> hashmap;\n        for (int i = 0; i < mapping.size(); i++)\n        {\n            hashmap[i] = mapping[i];\n        }\n        vector<string> updatedNums;\n        for (int n : nums)\n        {\n            updatedNums.push_back(to_string(n));\n        }\n        vector<pair<string, string>> paired;\n        for (string temp : updatedNums)\n        {\n            string res = "";\n            for (char x : temp)\n            {\n                res += (hashmap[x - \'0\']) + \'0\';\n            }\n            paired.push_back({res, temp});\n        }\n        vector<pair<int, int>> container;\n        for (pair<string, string> p : paired)\n        {\n            int a = stoi(p.first);\n            int b = stoi(p.second);\n            container.push_back({a, b});\n        }\n        sort(container.begin(), container.end(), comp);\n        vector<int> ans;\n        for (pair<int, int> c : container)\n        {\n            ans.push_back(c.second);\n        }\n        return ans;\n    }\n};\n\n```\n# Upvote\n![upvote meme.jpg](https://assets.leetcode.com/users/images/f322ac80-3b48-4eca-8e70-bb7e6e277cd1_1721806901.686743.jpeg)\n
['C++']