C++ || Video Solutiion || Easy Solution
YouTube Video\nhttps://youtu.be/y5PggCsdU-M\nDo find the video solution in the above video. Like the video if you found it helpful, Subscribe to the channel for
# YouTube Video\nhttps://youtu.be/y5PggCsdU-M\nDo find the video solution in the above video. Like the video if you found it helpful, Subscribe to the channel for the daily videos.\n# Code\n```\nclass Solution {\nprivate:\n    int count(int num){\n        int ans = 0;\n        while(num){\n            ans++;\n            num /= 10;\n        }\n        return ans;\n    }\n    int helper(vector<int> &mapping, int original){\n        if(original == 0) return mapping[0];\n        int replaced = 0;\n        int sz = count(original);\n        vector<int> v(sz, 0);\n        int idx = 0;\n        while(original){\n            v[idx] = mapping[original % 10];\n            idx++;\n            original /= 10;\n        }\n        for(int i = sz - 1 ; i >= 0 ; i--){\n            replaced = replaced*10 + v[i];\n        }\n        return replaced;\n    }\npublic:\n    vector<int> sortJumbled(vector<int>& mapping, vector<int>& nums) {\n        // 0 - 8\n        // 1 - 9\n        // 2 - 4\n        // 3 - 0\n        // 4 - 2\n        // 5 - 1\n        // 6 - 3 \n        // 7 - 5\n        // 8 - 7\n        // 9 - 6\n        // 991 - 669 - 0\n        // 338 - 007 - 7 - 1\n        // 38. - 07. - 7 - 2\n        // 338, 38, 991\n        // v - ({669, 0}, {7, 1}, {7, 2})\n        // v - ({7, 1}, {7, 2}, {669, 0})\n        vector<pair<int, int>> v;\n        vector<int> ans;\n        int sz = nums.size();\n        for(int i = 0 ; i < sz ; i++){\n            v.push_back({helper(mapping, nums[i]), i});\n        }\n        sort(v.begin(), v.end());\n        for(auto &ele : v) ans.push_back(nums[ele.second]);\n        return ans;\n    }\n};\n```
['C++']