Leetcode-cn.com 2021-09-03
🟡 面试题 17.14.smallest-k-lcci
🏷️ Tags
#array #divide_and_conquer #quickselect #sorting #heap_priority_queue
Description
设计一个算法,找出数组中最小的k个数。以任意顺序返回这k个数均可。
Example
🟡 面试题 17.14.smallest-k-lcci
🏷️ Tags
#array #divide_and_conquer #quickselect #sorting #heap_priority_queue
Description
设计一个算法,找出数组中最小的k个数。以任意顺序返回这k个数均可。
Example
输入: arr = [1,3,5,7,2,4,6,8], k = 4
输出: [1,2,3,4]
leetcode.com 2023-05-22
🟡347.top-k-frequent-elements
🏷️ Tags
#array #hash_table #divide_and_conquer #bucket_sort #counting #quickselect #sorting #heap_priority_queue
🟡347.top-k-frequent-elements
🏷️ Tags
#array #hash_table #divide_and_conquer #bucket_sort #counting #quickselect #sorting #heap_priority_queue
Telegraph
top-k-frequent-elements
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,1,1,2,2,3], k = 2 Output: [1,2] Example 2: Input: nums = [1], k = 1 Output: [1] Constraints:
leetcode.com 2023-08-14
🟡215.kth-largest-element-in-an-array
🏷️ Tags
#array #divide_and_conquer #quickselect #sorting #heap_priority_queue
🟡215.kth-largest-element-in-an-array
🏷️ Tags
#array #divide_and_conquer #quickselect #sorting #heap_priority_queue
Telegraph
kth-largest-element-in-an-array
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, not the kth distinct element. Can you solve it without sorting? Example 1: Input: nums = [3,2,1,5,6,4]…