Soln beating 98.86% (C++)| SORT
I created cpy arr to store number as well as its index\n After sorting cpy arr will be sorted\n then i take out last k element\'s index and i sort the ans\n* fo
* I created cpy arr to store number as well as its index\n* After sorting cpy arr will be sorted\n* then i take out last k element\'s index and i sort the ans\n* form array of idx in ans and return it\n```\nclass Solution {\npublic:\n    vector<int> maxSubsequence(vector<int>& nums, int k) {\n        if(k>nums.size())\n            return {};\n        if(k==nums.size())\n            return nums;\n        vector<pair<int,int>>cpy;\n        for(int i=0;i<nums.size();i++)\n        {\n            cpy.push_back({nums[i],i});\n        }\n        sort(cpy.begin(),cpy.end());\n        vector<int> ans;\n        for(int i=nums.size()-k;i<nums.size();i++)\n            ans.push_back(cpy[i].second);\n        sort(ans.begin(),ans.end());\n        vector<int> finala;\n        for(int i=0;i<ans.size();i++)\n        {\n            finala.push_back(nums[ans[i]]);\n        }\n        return finala;\n    }\n};\n```
['C', 'Sorting']