Top K Frequent Elements (LeetCode 347) | Neetcode 5/ 150 | Bharath Chandra (తెలుగు)

  Рет қаралды 1,219

Bharath Chandra (తెలుగు)

Bharath Chandra (తెలుగు)

Күн бұрын

Hello guys, cheers to another piece of learning. Today I talked about the "Top K Frequent Elements" problem which is the first in Neetcode 150 list. It is one of the most asked questions in interviews and has some interesting ways to solve it.
In the above video, I showed all the different logics with which the problem can be solved and also the codes to those logics in Python. Let me know if you got a hold of the logic?
Link to Hashsets and Hashmaps video - • Hashsets and HashMaps ...
Link to the problem - leetcode.com/problems/top-k-f...
Link to Java, C++ solution - leetcode.com/problems/top-k-f...
Link to Python Solution - leetcode.com/problems/top-k-f...
Link to Neetcode 150 - neetcode.io/practice=
Regular updates from me on Discord, Insta and Telegram. I post job notifications of telegram and discord
Insta - / bharathh_chandraa
Telegram - t.me/thebharathchandra
Discord - / discord
00:00 - Introduction and Problem Statement
01:51 - HashMap step
07:15 - Approach 1 with intuition
13:57 - Approach 2 with intution
22:49 - Approach 2 example
34:46 - Pseudocode
38:40 - Code and Conclusion

Пікірлер: 27
@pullareddy_yanamala_
@pullareddy_yanamala_ 19 күн бұрын
niceee🎉
@Manjith-1887
@Manjith-1887 27 күн бұрын
Excited For Daily Two Problems 🤞💥
@bharathh_chandraa
@bharathh_chandraa 27 күн бұрын
So am I Manjith! Brace yourselves🙌🏻
@vaneetha_here_navaneetha
@vaneetha_here_navaneetha 18 күн бұрын
class Solution(object): def topKFrequent(self, nums, k): hashMap={} for i in nums: if i in hashMap: hashMap[i] = hashMap[i]+1 else: hashMap[i] = 1 l=[] for i in range(k): max_key = max(hashMap, key=hashMap.get) l.append(max_key) del hashMap[max_key] return l before staring the video
@_Siva_krishna_karri
@_Siva_krishna_karri 26 күн бұрын
Anna nice explanation with real time examples. hope anni sums lo ila real time examples use cheyali ani korukuntunna🤩
@electron-u8p
@electron-u8p 17 күн бұрын
5/150 ✅️
@abhiramvanama5266
@abhiramvanama5266 19 күн бұрын
python lone continue cheyyi anna , itss looks like psuedo code , and pyhton lo cheppe vallu chala thakkuva unnaru
@ghani2342
@ghani2342 27 күн бұрын
Thanks anna
@VamsiNathReddy-hh8yd
@VamsiNathReddy-hh8yd 27 күн бұрын
Nice anna
@techdevilsgaming1574
@techdevilsgaming1574 27 күн бұрын
Bro code Java lo rayyandi
@maheswara_pradeep8235
@maheswara_pradeep8235 27 күн бұрын
Let's goooooo. Solved it using sort
@bharathh_chandraa
@bharathh_chandraa 27 күн бұрын
Another feather in your hat now!
@vaneetha_here_navaneetha
@vaneetha_here_navaneetha 18 күн бұрын
linkedin link petttaledhu🤔
@vaneetha_here_navaneetha
@vaneetha_here_navaneetha 18 күн бұрын
lokesh anna,something is missing,ee video ki previous videos ki mundhu videos laga ney cheyandi anna better ga artham avuthundhi. meru em worry avvakandi viewers ni memu thisukoni vastham. but ee video little bit tricky to understand
@learn_with_bharath
@learn_with_bharath 12 күн бұрын
bro try to minimize the length of video bcz seeing long video can be bored or not intrested to watch end overall nice explanation about every possible example thanks bro
@bharathh_chandraa
@bharathh_chandraa 12 күн бұрын
Sure Bharath! Keep Coding
@kesavakk124
@kesavakk124 18 күн бұрын
Make a video on heaps in python
@bharathh_chandraa
@bharathh_chandraa 18 күн бұрын
Ee playlist lo anni data structures paina problems osthay. Heaps problems solve chese mundhu concept discuss chesthanu
@kesavakk124
@kesavakk124 17 күн бұрын
@@bharathh_chandraa ok bruh Your videos are damn good.Thanks for helping us
@LearnSpokenEnglishWithMe
@LearnSpokenEnglishWithMe 14 күн бұрын
Bro after frequency Calculate chesaka Hash Map ni sort (Based on values chesi) K keys ni return chesthe avvutundaa?
@bharathh_chandraa
@bharathh_chandraa 12 күн бұрын
Yes, if your language supports sorting based on values.
@shanmukharao3378
@shanmukharao3378 15 күн бұрын
Hi Bharath, C# doesn't have HashTable Sort by value. any other way we can do. By Value.
@bharathh_chandraa
@bharathh_chandraa 15 күн бұрын
You have to create an array of pairs. And then sort based on values, most of the languages don’t allow sort by values. Else use the countArray approach, it is more efficient
@shanmukharao3378
@shanmukharao3378 14 күн бұрын
​@@bharathh_chandraa Approach 2: Completed. All Test case passed. But in c# when using Hashtable every time i have to cast value.
@ranjanreddy3296
@ranjanreddy3296 19 күн бұрын
Bro only 2 approaches kada.. 1) hashmap with sorting, 2) hashmap without sorting.. TImeline lo approach 2 and approach 3 undhi, is that a typo ? Also approach 2 lo kuda you need to create a 2nd hash map right ? else how do you know the key if you just sort the values.
@bharathh_chandraa
@bharathh_chandraa 18 күн бұрын
Thanks for pointing this out Ranjan. 2 approaches ee unnay typo adhi. Sorting approach lo you need an other array of pairs to maintain the keys and values together while sorting
String Encode and Decode (LeetCode 271) | Neetcode 6 / 150 | Bharath Chandra (Telugu)
37:24
Bharath Chandra (తెలుగు)
Рет қаралды 971
P30 - Static and Non static in java | Core Java | Java Programming |
59:18
H Y R Tutorials - Telugu
Рет қаралды 92 М.
50 YouTubers Fight For $1,000,000
41:27
MrBeast
Рет қаралды 210 МЛН
What it feels like cleaning up after a toddler.
00:40
Daniel LaBelle
Рет қаралды 87 МЛН
НЫСАНА КОНЦЕРТ 2024
2:26:34
Нысана театры
Рет қаралды 1,4 МЛН
Best KFC Homemade For My Son #cooking #shorts
00:58
BANKII
Рет қаралды 69 МЛН
BINARY TREE TRAVERSALS WITH EXAMPLE - DATA STRUCTURES
22:56
Sundeep Saradhi Kanthety
Рет қаралды 90 М.
Stop Being Average 😩 How to Be in Top 1% 🔥
12:21
Swaroop VITB
Рет қаралды 34 М.
Best Time to Buy and Sell Stock(LeetCode 121) | Neetcode 15 / 150 | Bharath Chandra (Telugu)
15:02
Valid Anagram (LeetCode 242) | Neetcode 2 / 150 | Bharath Chandra (తెలుగు)
24:16
Bharath Chandra (తెలుగు)
Рет қаралды 1,6 М.
These Coding Projects Give You An Unfair Advantage
14:39
Harkirat Singh
Рет қаралды 342 М.
50 YouTubers Fight For $1,000,000
41:27
MrBeast
Рет қаралды 210 МЛН