/** * Your KthLargest object will be instantiated and called as such: * KthLargest obj = new KthLargest(k, nums); * int param_1 = obj.add(val); */ int main() { int k = 3; vector<int> v = {4, 5, 8, 2}; KthLargest *kthLargest = new KthLargest(k, v); // print_queue(kthLargest->pq); vector<int> nums = {3, 5, 10, 9, 4}; for (int i = 0; i < nums.size(); i++) { cout << kthLargest->add(nums[i]) << endl; } }
/** * Your KthLargest object will be instantiated and called as such: * KthLargest* obj = new KthLargest(k, nums); * int param_1 = obj->add(val); */ int main() { int k = 3; vector<int> nums = {4,5,8,2}; KthLargest* obj = new KthLargest(k, nums); //["KthLargest","add","add","add","add","add"] // length >= k - 1 //[[2,[0]],[-1],[1],[-2],[-4],[3]] //["KthLargest","add","add","add","add","add"] // [[3,[4,5,8,2]],[3],[5],[10],[9],[4]] // [null,3,4,5,8,8] // [null,4,5,5,8,8] cout << obj->add(3) << endl; cout << obj->add(5) << endl; cout << obj->add(10) << endl; cout << obj->add(9) << endl; cout << obj->add(4) << endl; //int param_1 = obj->add(3); }