Here's How to use a HEAP | Top K Frequent Elements - Leetcode 347

Sdílet
Vložit
  • čas přidán 29. 08. 2024
  • leetcode, coding interview question, data structures, data structures and algorithms, faang

Komentáře • 19

  • @GregHogg
    @GregHogg  Před 7 měsíci

    Master Data Structures & Algorithms For FREE at AlgoMap.io!

  • @tejakovvuri3042
    @tejakovvuri3042 Před 2 měsíci +3

    Learnt heap with a single short 😂, kudos to you.

  • @danielshin2047
    @danielshin2047 Před 8 měsíci +1

    Epic 😎
    I love your shorts. Nice elegant code

  • @KunalSingh-ol6zx
    @KunalSingh-ol6zx Před 8 měsíci +1

    Unordered_map is good choice?

  • @Ford-ju9yr
    @Ford-ju9yr Před 4 měsíci

    Why not O(n+k×ln(k))?

    • @Ford-ju9yr
      @Ford-ju9yr Před 4 měsíci

      Also in the beginning you say you solved it in O(n). Why bother with slower solution?

    • @millfreedom
      @millfreedom Před měsícem

      @@Ford-ju9yrfor k

  • @QwDragon
    @QwDragon Před 8 měsíci +1

    Counter has most_common method.

  • @cillwish
    @cillwish Před 8 měsíci

    What is counter time complexity

    • @GregHogg
      @GregHogg  Před 8 měsíci +1

      O(n)

    • @prawnydagrate
      @prawnydagrate Před 8 měsíci

      lmao what else do u think it could be it literally just adds 1 for each occurrence

    • @GregHogg
      @GregHogg  Před 8 měsíci +1

      It uses a dictionary, which is hashing

    • @deeps-n5y
      @deeps-n5y Před 6 měsíci +2

      @@prawnydagrate what's in it to laugh? someone asked a question, if you can answer it then do it else move on!

  • @MurderByProxy
    @MurderByProxy Před 8 měsíci +1

    I cant take this dude seriously… first he codes on python and then his voice breaks lol

    • @anova3607
      @anova3607 Před 8 měsíci +2

      Post a video of you speaking then tough guy

    • @6hbaufhehdj
      @6hbaufhehdj Před 8 měsíci +2

      What would you code in? You do know that if you can code in one language you have the ability to code in another language you just need to learn the syntax …