C++, simple, priority queue, beats 90% runtime
Code\n\nclass Solution {\npublic:\n    vector<int> maxSubsequence(vector<int>& nums, int k) {\n        vector<int> result;\n        result.reserve(k);\n        
# Code\n```\nclass Solution {\npublic:\n    vector<int> maxSubsequence(vector<int>& nums, int k) {\n        vector<int> result;\n        result.reserve(k);\n        // min heap, pair: nums[i], index\n        priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> pq;\n\n        for (int i = 0; i < nums.size(); i++) {\n            // grow the window\n            if (i < k) {\n                pq.push({nums[i], i});\n                continue;\n            }\n\n            // nums[i] is greater than the smallest element\n            if (nums[i] > pq.top().first) {\n                pq.pop();     \n                pq.push({nums[i], i});\n            }\n        }\n\n        // index, nums[i]\n        vector<pair<int,int>> v;\n        v.reserve(k);\n        \n        while (!pq.empty()) {\n            v.emplace_back(pq.top().second, pq.top().first);\n            pq.pop();\n        }\n\n        sort(v.begin(), v.end());\n        // v.size() will be k, so use k instead\n        for (int i = 0; i < k; i++) {\n            result.emplace_back(v[i].second);\n        }\n\n        return result;\n    }\n};\n```
['Array', 'Sorting', 'Heap (Priority Queue)', 'C++']