Easy code using heap|| Beginner Friendly|| Well commented
Approach:\n1)Declare a max heap(since we need maximum sum) with datatype as pair of  to store the value of element present in given array along with the index.\
*Approach:\n1)Declare a max heap(since we need maximum sum) with datatype as pair of <int,int> to store the value of element present in given array along with the index.\n2)Push all the elements of given vector along with its index into the heap .\n3)Separate out the top \'k\' index from heap and store it in a vector.\n4)Sort the vector containing indexes so that the order of elements present at those indexdes is maintained.\n5)Decalre a new vector to store the values of elements present at these separated out indexes.\n6)Return this vector containing values of elements.*\n\n\nclass Solution {\npublic:\n    vector<int> maxSubsequence(vector<int>& nums, int k) {\n\t\n        priority_queue<pair<int,int>> pq;\n        for(int i=0;i<nums.size();i++)\n            pq.push({nums[i],i});\n        \n        vector<int> index;\n        while(k--){\n            pair<int,int> t=pq.top();\n            index.push_back(t.second);\n            pq.pop();\n        }\n        sort(index.begin(),index.end());\n        \n        vector<int> ans;\n        for(int i=0;i<index.size();i++)\n            ans.push_back(nums[index[i]]);\n        \n        return ans;\n    }\n};\n\n\nPlease upvote if you liked the solution :)
['C', 'Heap (Priority Queue)', 'C++']