SIMPLE MIN-HEAP C++ SOLUTION
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n//nums = [-1, -2, 3, 4] and k = 3\n// Iterate through each element in nums:\n// i = 0: Push (-1, 0) into the heap.\n// i = 1: Push (-2, 1) into the heap. Heap now has (-2, 1), (-1, 0).\n// i = 2: Push (3, 2) into the heap. Heap now has (-2, 1), (-1, 0), (3, 2).\n// i = 3: Push (4, 3) into the heap. Heap now has (-2, 1), (-1, 0), (3, 2), (4, 3). Since the heap size exceeds k, pop the smallest element, which is (-2, 1). Heap becomes (-1, 0), (3, 2), (4, 3).\n// 3. Extracting from the Min-Heap: \n// map will be in sorted order on the basis of index \n// Transfer elements from the heap to a map where the key is the index and the value is the number. This will automatically sort them by index.\n// Pop (-1, 0), (3, 2), and (4, 3) from the heap and insert into the map. The map now has {0: -1, 2: 3, 3: 4}\n// ans = [-1, 3 ,4 ].\nclass Solution {\npublic:\n    vector<int> maxSubsequence(vector<int>& nums, int k) {\n      priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q;// minheap \n        for(int i = 0; i < nums.size(); i++){\n            q.push({nums[i], i});\n            if (q.size() > k) {\n                q.pop();\n            }\n        }\n        map<int,int> m;// \n        while(!q.empty()){\n            m.insert({q.top().second,q.top().first});\n            q.pop();\n        }\n        vector<int>ans;\n        for (auto&x : m){\n            ans.push_back(x.second);\n        }\n\n        return ans;\n    }\n};\n```
['C++']