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

แชร์
ฝัง
  • เผยแพร่เมื่อ 29 ส.ค. 2024
  • leetcode, coding interview question, data structures, data structures and algorithms, faang

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

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

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

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

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

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

    Epic 😎
    I love your shorts. Nice elegant code

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

      Thank you!

  • @KunalSingh-ol6zx
    @KunalSingh-ol6zx 8 หลายเดือนก่อน +1

    Unordered_map is good choice?

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

    Counter has most_common method.

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

      Yeah! :)

  • @Ford-ju9yr
    @Ford-ju9yr 4 หลายเดือนก่อน

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

    • @Ford-ju9yr
      @Ford-ju9yr 4 หลายเดือนก่อน

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

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

      @@Ford-ju9yrfor k

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

    What is counter time complexity

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

      O(n)

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

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

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

      It uses a dictionary, which is hashing

    • @deeps-n5y
      @deeps-n5y 6 หลายเดือนก่อน +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 8 หลายเดือนก่อน +1

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

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

      Post a video of you speaking then tough guy

    • @6hbaufhehdj
      @6hbaufhehdj 8 หลายเดือนก่อน +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 …