Minimum Number of Pushes to Type Word II - Leetcode 3016 - Python

แชร์
ฝัง
  • เผยแพร่เมื่อ 12 ก.ย. 2024

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

  • @adiyansd4356
    @adiyansd4356 หลายเดือนก่อน +4

    First comment pin me bro📌

    • @NeetCodeIO
      @NeetCodeIO  หลายเดือนก่อน +11

      Fine but you better not edit it

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

      😂😂 ​@@NeetCodeIO

  • @ameyakhot4458
    @ameyakhot4458 หลายเดือนก่อน +12

    That "back in my day" hits different since we're not even that old to use this phrase.

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

      im 21 and this also applies to me

  • @BikerInsights
    @BikerInsights หลายเดือนก่อน +6

    I just saw the problem was II then solved first one and then came straight to Neetcode for explanation

  • @yang5843
    @yang5843 หลายเดือนก่อน +10

    The problem description is too long

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

      These interns need to have their writing skills vetted 😂

  • @dipakmaity2205
    @dipakmaity2205 หลายเดือนก่อน +5

    reading the problem makes you feel like a nightmare but we actually its not ... well hurrah solved it w/o seeing ur video or intuition

  • @ajitpalsingh606
    @ajitpalsingh606 หลายเดือนก่อน +4

    Done on my own

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

    Damn Ascii values to solve this problem was genius!!

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

    i think you should start a codeforces series leetcode is getting easy

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

    Thank you broski I had the right idea and was working on it but the explanation really helped me out. However, one small suggestion maybe include the previous problem in the description since I did that one first and it helped out when moving onto the second. Great video!!!

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

    first daily medium I solved by myself, all thanks to your channel

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

    Solved it on my own. A bit easy problem.

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

    for counting you can use a hash map with characters as keys and then get the sorted array of values by using list(dict.values()) and then sort

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

    really loved the explanation. thank you neetcode!

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

    I wanted to know is there any improvement or advantages of using heap way rather than just sorting?

    • @Film-Screen
      @Film-Screen หลายเดือนก่อน

      in this problem no, but in othere problems if u need to make alot of del, insert and keep maintaining a sorted array heap would be much better in time complixty

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

    Could you please explain this problem - Time Taken to Mark All Nodes (LeetCode - 3241). Please...

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

    Thanks a Lot G!

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

    class Solution:
    def minimumPushes(self, word: str) -> int:
    d=dict(Counter(word))
    m=[]
    for i,j in d.items():
    m.append((j,i))
    m.sort(reverse=True)
    print(m)
    c=2
    s=0
    a=0
    for p,q in m:
    if c9 and c=18 and c=26:
    s+=(p*4)
    c+=1
    return s
    we could solve the problem with this approach as well @NeetCodeIO

  • @MP-ny3ep
    @MP-ny3ep หลายเดือนก่อน

    Thank you for the daily

  • @JamesBond-mq7pd
    @JamesBond-mq7pd หลายเดือนก่อน

    super clever. !

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

    broo isn't the time complexity just O(n)?

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

      @@7akon yeah he said O(NlogN)..... But its just O(N)

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

      sorting is O(NlogN)

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

      @@guy_cod yeah like for an ideal case it is O(NlogN)... But we are sorting a constant space list ie, 26 so it takes constant time.. So overall just O(N)

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

      @@krupakarreddy1758 thank you for the explanation

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

    You just understand the examples for this question, you will find the approach

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

    Nice

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

    class Solution:
    def minimumPushes(self, word: str) -> int:
    MAX_BUTTONS = 8
    count_keys = 0
    pushes = 0
    for key in Counter(word).most_common():
    pushes += key[1] * (1 + count_keys // MAX_BUTTONS)
    count_keys += 1
    return pushes

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

    Sometimes, I feel like I am God before watching the video,I was able to come with a solution, but I came here to see his approach. the approach is same❤

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

    How about this?
    class Solution:
    def minimumPushes(self, word: str) -> int:
    c=list(Counter(word).items())
    c.sort(key=lambda x:x[1],reverse=True)
    count=0
    k=1
    for i,j in enumerate(c,start=1):
    count+= j[1]*k
    if i%8==0:
    k+=1
    return count

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

    return sum(c*(1+i//8)for i,c in enumerate(sorted(Counter(w).values(),reverse=1)))

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

      This sol is from larry.

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

    The rent is too damn high!