摘要:
Design a class to find the kth largest element in a stream. Note that it is the kth largest element in the sorted order, not the kth distinct element. 阅读全文
随笔档案-2021年6月28日
[LeetCode] 347. Top K Frequent Elements_Medium tag: Array, Heap, quickSort
2021-06-28 09:51 by Johnson_强生仔仔, 82 阅读, 收藏,
摘要:
Given an integer array nums and an integer k, return the k most frequent elements. You may return the answer in any order. Example 1: Input: nums = [1 阅读全文
[LeetCode] 215. Kth Largest Element in an Array_Medium tag: sort, Heap, quickSort
2021-06-28 09:04 by Johnson_强生仔仔, 64 阅读, 收藏,
摘要:
Given an integer array nums and an integer k, return the kth largest element in the array. Note that it is the kth largest element in the sorted order 阅读全文
quickSort use two pointers to decrease Time into O(n * lgn ) or O(n)
2021-06-28 08:45 by Johnson_强生仔仔, 62 阅读, 收藏,
摘要:
Quicksort, 选取pivot, 然后有两个指针, left = 0, right = n - 1, left 不停右移找到nums[left] > pivot, right 不停左移找到nums[right] <= pivot直到left >= right, 停止,那么这时候再recursi 阅读全文
浙公网安备 33010602011771号