C++ | Partial sort
c++\nclass Solution {\npublic:\n    vector<int> maxSubsequence(vector<int>& nums, int k) {\n        \n        vector<pair<int,int>> numWithIndex(size(nums));\n 
```c++\nclass Solution {\npublic:\n    vector<int> maxSubsequence(vector<int>& nums, int k) {\n        \n        vector<pair<int,int>> numWithIndex(size(nums));\n        for(int i = 0; i < size(nums); i++) numWithIndex[i] = {nums[i], i};\n        \n        partial_sort(begin(numWithIndex), \n                     begin(numWithIndex) + k, \n                     end(numWithIndex),\n                     [](auto &left, auto &right) {\n            return left.first > right.first;\n        });\n        \n        vector<int> result;\n        sort(begin(numWithIndex), \n             begin(numWithIndex) + k, \n             [](pair<int, int> a, pair<int, int> b) {\n            return a.second < b.second;\n        });\n        \n        for (int i = 0; i < k; i++ ) result.push_back(numWithIndex[i].first);       \n        return result;\n    }\n};\n```\n\n**For more solutions, check out this \uD83C\uDFC6  [GITHUB REPOSITORY](https://github.com/MuhtasimTanmoy/playground) with over 1500+ solutions.**
['Heap (Priority Queue)']