Top K Frequent Elements - 347. LeetCode - Java

  Рет қаралды 634

Teddy Smith

Teddy Smith

Күн бұрын

Пікірлер: 4
@venzdrop
@venzdrop 10 күн бұрын
from collections import Counter class Solution: def topKFrequent(self, nums: List[int], k: int) -> List[int]: f = Counter(nums) return [x[0] for x in f.most_common(k)]
@KarthiKarthi-df2mp
@KarthiKarthi-df2mp 2 ай бұрын
You have nailed the explanation, its perfect.....but what if the top k is 2 and the last list in an bucket as 5 numbers?
@TeddySmithDev
@TeddySmithDev 2 ай бұрын
It will store those numbers under bucket[6] within nested list. The nested list gives the ability to add multiple numbers within array and when it iterates backwards it will get those two numbers. If I did not understand your question correct, please comment again and i will look.
@KarthiKarthi-df2mp
@KarthiKarthi-df2mp 2 ай бұрын
Thanks for the explanationsl man!....I got it thank you very much....looking for lot more videos with this wonderful explanation.
Plus One - 66. LeetCode - Java
6:53
Teddy Smith
Рет қаралды 261
Top K Frequent Elements - Bucket Sort - Leetcode 347 - Python
13:13
1% vs 100% #beatbox #tiktok
01:10
BeatboxJCOP
Рет қаралды 67 МЛН
Enceinte et en Bazard: Les Chroniques du Nettoyage ! 🚽✨
00:21
Two More French
Рет қаралды 42 МЛН
Combination Sum - 39. LeetCode - Java
16:30
Teddy Smith
Рет қаралды 169
Trapping Rain Water - 42. LeetCode - Java
9:19
Teddy Smith
Рет қаралды 746
Java HashMap 🗺️
13:05
Bro Code
Рет қаралды 94 М.
How to Solve ANY LeetCode Problem (Step-by-Step)
12:37
Codebagel
Рет қаралды 351 М.
25 nooby Python habits you need to ditch
9:12
mCoding
Рет қаралды 1,8 МЛН
Search in Rotated Sorted Array - 33. LeetCode - Java
11:24
Teddy Smith
Рет қаралды 199
but what is 'a lifetime?
12:20
leddoo
Рет қаралды 89 М.
Rotate Array - 189. LeetCode - Java
8:44
Teddy Smith
Рет қаралды 975