C++ || Simple to understand || ✔✔
Complexity\n- Time complexity: O(nlogn)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(n)\n Add your space complexity here, e.g. O(n) \n\n
## Complexity\n- Time complexity: $$O(nlogn)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(n)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    vector<int> maxSubsequence(vector<int>& nums, int k) {\n        multiset<int> mset;\n        vector<int> ans;\n        for (int i=0; i<nums.size(); i++){\n            mset.insert(nums[i]);\n        }\n        while (mset.size()>k)mset.erase(mset.begin());\n        for (int i=0; i<nums.size(); i++){\n            auto it= mset.find(nums[i]);\n            if (it!=mset.end()){\n                ans.push_back(nums[i]);\n                mset.erase(it);\n            }\n        }\n        return ans;\n    }\n};\n```
['Array', 'Hash Table', 'Sorting', 'Ordered Set', 'C++']