题目:原题链接(中等)
标签:堆
解法 | 时间复杂度 | 空间复杂度 | 执行用时 |
Ans 1 (Python) | O ( K l o g N ) | O ( N ) | 124ms (47.35%) |
Ans 2 (Python) | |||
Ans 3 (Python) |
解法一:
class Solution:
def smallestK(self, arr: List[int], k: int) -> List[int]:
return heapq.nsmallest(k, arr)
微信扫一扫
题目:原题链接(中等)
标签:堆
解法 | 时间复杂度 | 空间复杂度 | 执行用时 |
Ans 1 (Python) | O ( K l o g N ) | O ( N ) | 124ms (47.35%) |
Ans 2 (Python) | |||
Ans 3 (Python) |
解法一:
class Solution:
def smallestK(self, arr: List[int], k: int) -> List[int]:
return heapq.nsmallest(k, arr)
相关推荐