标签:param nbsp add private ges ret queue style cal
class KthLargest { public: KthLargest(int k, vector<int> nums) { size = k; for(auto num:nums){ pq.push(num); if(pq.size() > size) pq.pop(); } } int add(int val) { pq.push(val); if(pq.size() > size) pq.pop(); return pq.top(); } private: priority_queue<int, vector<int>, greater<int>> pq; int size; }; /** * Your KthLargest object will be instantiated and called as such: * KthLargest obj = new KthLargest(k, nums); * int param_1 = obj.add(val); */
标签:param nbsp add private ges ret queue style cal
原文地址:https://www.cnblogs.com/asenyang/p/9734865.html