- Notifications
You must be signed in to change notification settings - Fork2.4k
Closed
Description
Bug Report for https://neetcode.io/problems/two-integer-sum
class Solution:
def topKFrequent(self, nums: List[int], k: int) -> List[int]:
h = {}
for i in nums: if i not in h: h[i] = 0 h[i] += 1 heap = [] for i in h.keys(): heapq.heappush(heap, (h[i], i)) if len(heap) > k: heapq.heappop(heap) res = [] for i in range(k): res.append(heapq.heappop(heap)[1]) return res
i ran my code, and it says i got the wrong answer for this test case
nums=[1,2,3,4,5,6,6,7,8]
k=2
but when i run my code on the leetcode website, it successfully submitted, and when i try that test case, it says its an invalid test case. I even tried your heap solution and sorted solution and its the same problem
Metadata
Metadata
Assignees
Labels
No labels