leetcode每日一题在哪-interviewalgorithms:面试算法

时间:2024-07-20 00:50:44
【文件属性】:

文件名称:leetcode每日一题在哪-interviewalgorithms:面试算法

文件大小:6KB

文件格式:ZIP

更新时间:2024-07-20 00:50:44

系统开源

leetcode 每日一题在哪2020 年问题: 找到重复的号码 # goes through and makes the # Time: O(n) # Space: O(1) def findDuplicate ( self , nums : List [ int ]) -> int : for i in range ( len ( nums )): if nums [ abs ( nums [ i ]) - 1 ] < 0 : return abs ( nums [ i ]) else : nums [ abs ( nums [ i ]) - 1 ] = - nums [ abs ( nums [ i ]) - 1 ] return - 1 前 K 个频繁元素 # keep track of the elements in a minheap with their count in first index. # Time: O(nlog(k)) # Space: O(k) def topKFrequent ( self , nums , k ): if not nums : ret


【文件预览】:
interviewalgorithms-master
----README.md(15KB)

网友评论