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

แชร์
ฝัง
  • เผยแพร่เมื่อ 7 ส.ค. 2024
  • 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

ความคิดเห็น • 28

  • @Manjith-1887
    @Manjith-1887 หลายเดือนก่อน +4

    Excited For Daily Two Problems 🤞💥

    • @bharathh_chandraa
      @bharathh_chandraa  หลายเดือนก่อน +1

      So am I Manjith! Brace yourselves🙌🏻

  • @_Siva_krishna_karri
    @_Siva_krishna_karri หลายเดือนก่อน +1

    Anna nice explanation with real time examples. hope anni sums lo ila real time examples use cheyali ani korukuntunna🤩

  • @vaneetha_here_navaneetha
    @vaneetha_here_navaneetha 23 วันที่ผ่านมา +2

    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

  • @techdevilsgaming1574
    @techdevilsgaming1574 หลายเดือนก่อน +2

    Bro code Java lo rayyandi

  • @VendiChitralu
    @VendiChitralu 2 วันที่ผ่านมา

    Bro expalination peaks but code tho step by step explain cheyy 🙏

  • @pullareddy_yanamala_
    @pullareddy_yanamala_ 23 วันที่ผ่านมา

    niceee🎉

  • @VamsiNathReddy-hh8yd
    @VamsiNathReddy-hh8yd หลายเดือนก่อน

    Nice anna

  • @ghani2342
    @ghani2342 หลายเดือนก่อน

    Thanks anna

  • @electron-u8p
    @electron-u8p 22 วันที่ผ่านมา

    5/150 ✅️

  • @maheswara_pradeep8235
    @maheswara_pradeep8235 หลายเดือนก่อน

    Let's goooooo. Solved it using sort

  • @abhiramvanama5266
    @abhiramvanama5266 24 วันที่ผ่านมา

    python lone continue cheyyi anna , itss looks like psuedo code , and pyhton lo cheppe vallu chala thakkuva unnaru

  • @vaneetha_here_navaneetha
    @vaneetha_here_navaneetha 23 วันที่ผ่านมา

    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 17 วันที่ผ่านมา

    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

  • @vaneetha_here_navaneetha
    @vaneetha_here_navaneetha 23 วันที่ผ่านมา

    linkedin link petttaledhu🤔

  • @LearnSpokenEnglishWithMe
    @LearnSpokenEnglishWithMe 19 วันที่ผ่านมา

    Bro after frequency Calculate chesaka Hash Map ni sort (Based on values chesi) K keys ni return chesthe avvutundaa?

    • @bharathh_chandraa
      @bharathh_chandraa  17 วันที่ผ่านมา

      Yes, if your language supports sorting based on values.

  • @kesavakk124
    @kesavakk124 23 วันที่ผ่านมา

    Make a video on heaps in python

    • @bharathh_chandraa
      @bharathh_chandraa  23 วันที่ผ่านมา

      Ee playlist lo anni data structures paina problems osthay. Heaps problems solve chese mundhu concept discuss chesthanu

    • @kesavakk124
      @kesavakk124 21 วันที่ผ่านมา

      @@bharathh_chandraa ok bruh
      Your videos are damn good.Thanks for helping us

  • @shanmukharao3378
    @shanmukharao3378 19 วันที่ผ่านมา

    Hi Bharath, C# doesn't have HashTable Sort by value. any other way we can do. By Value.

    • @bharathh_chandraa
      @bharathh_chandraa  19 วันที่ผ่านมา

      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 19 วันที่ผ่านมา

      ​@@bharathh_chandraa Approach 2: Completed. All Test case passed. But in c# when using Hashtable every time i have to cast value.

  • @ranjanreddy3296
    @ranjanreddy3296 23 วันที่ผ่านมา

    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  23 วันที่ผ่านมา

      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