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

Поделиться
HTML-код
  • Опубликовано: 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 …