Simple C++ solution [Runtime - 8ms beats 80%]
\n# Code\n\nclass Solution {\npublic:\n    vector<int> maxSubsequence(vector<int>& nums, int k) {\n        int sum =0;\n        priority_queue<pair<int, int>,ve
\n# Code\n```\nclass Solution {\npublic:\n    vector<int> maxSubsequence(vector<int>& nums, int k) {\n        int sum =0;\n        priority_queue<pair<int, int>,vector<pair<int, int>>,greater<pair<int, int>>> pq;\n        for(int i=0;i<nums.size();i++)\n        {\n            pq.push({nums[i],i});\n        }\n        int i=nums.size()-k;\n        while(i>0)\n        {\n            pq.pop();\n            i--;\n        }\n        priority_queue<pair<int, int>,vector<pair<int, int>>,greater<pair<int, int>>> pq2;\n        while(!pq.empty())\n        {\n                pq2.push({pq.top().second,pq.top().first});\n                pq.pop();\n        }\n        nums.resize(0);\n        while(!pq2.empty())\n        {\n            nums.push_back(pq2.top().second);\n            pq2.pop();\n        }\n        return nums;\n    }\n};\n```
['Sorting', 'Heap (Priority Queue)', 'C++']