Easy C++ solution
\ntypedef pair<int,int> p;\nclass Solution {\npublic:\n    vector<int> maxSubsequence(vector<int>& nums, int k) {\n        // Heap \'q\' will store the k larges
```\ntypedef pair<int,int> p;\nclass Solution {\npublic:\n    vector<int> maxSubsequence(vector<int>& nums, int k) {\n        // Heap \'q\' will store the k largest elements of the array \n        // The following heap is of pair where first element of pair is the element and the second element is the corresponding index\n        // That\'s how in queue sorting will be done according to the array element\n        priority_queue<p,vector<p>,greater<p>>q;\n        for(int i=0;i<nums.size();i++)\n        {\n            q.push({nums[i],i});\n            if(q.size()>k)\n            {\n                q.pop();\n            }\n        }\n        \n        // heap \'aux\' will sort the elements based on their index\n        // sorting according to the index is necessary in order get the original order of the elements \n\t\t// in the following heap the first element of the pair is the index and the second element is the array element itself\n        priority_queue<p,vector<p>,greater<p>>aux;\n        while(!q.empty())\n        {\n            aux.push({q.top().second,q.top().first});\n            q.pop();\n        }\n        \n        // once the elements are sorted according to their indices , push them in a vector\n        vector<int>ans;\n        while(!aux.empty())\n        {\n            ans.push_back(aux.top().second);\n            aux.pop();\n        }\n        \n        // finally return the answer\n        return ans;\n    }\n};\n```\n***Please upvote if you have got any help from my code. Thank you.***
['C', 'Heap (Priority Queue)']