Successful Pairs of Spells and Potions - Leetcode 2300 - Python

Sdílet
Vložit
  • čas přidán 24. 07. 2024
  • 🚀 neetcode.io/ - A better way to prepare for Coding Interviews
    Solving Leetcode 2300 - Successful Pairs of Spells and Potions, today's daily leetcode problem on April 1st.
    🥷 Discord: / discord
    🐦 Twitter: / neetcode1
    🐮 Support the channel: / neetcode
    ⭐ BLIND-75 PLAYLIST: • Two Sum - Leetcode 1 -...
    💡 DYNAMIC PROGRAMMING PLAYLIST: • House Robber - Leetco...
    Problem Link: leetcode.com/problems/success...
    0:00 - Read the problem
    1:15 - Drawing Explanation
    8:00 - Coding Explanation
    leetcode 2300
    #neetcode #leetcode #python

Komentáře • 38

  • @tanish5662
    @tanish5662 Před rokem +59

    missed you more than my girlfriend, thanks for being in my life

    • @Tehnubwaffle
      @Tehnubwaffle Před 8 měsíci +7

      A girlfriend has too many edge cases

  • @MP-ny3ep
    @MP-ny3ep Před rokem +7

    Thank you ! Please keep doing the daily leetcode questions. They're very helpful/motivating,

  • @asmahamdym
    @asmahamdym Před rokem +7

    when you do the leetcode daily questions I feel like I have backup😃
    Thanks for that

  • @deepakprasanna6798
    @deepakprasanna6798 Před rokem +2

    Thanks Neetcode for the intuition. One small issue I had in my code is, I had my append statement in this way, --> res.append(len(potions[idx:])) I was hit with Time Limit Exceeded error. I then followed your approach and corrected with res.append(len(potions) - idx)) it worked for me. Just thought to share

  • @gilesbbb
    @gilesbbb Před 11 měsíci +2

    I feel like I've reached a milestone. I didn't check your video before solving the problem and my solution was a sort + binary search like yours. OMG!!!!!!

  • @bhushanmahajan2150
    @bhushanmahajan2150 Před rokem +2

    Instead of declaring a new var "idx", we can simply use the left value. So when binary search is done, we have the furthest left value in "l". Therefore, we can simply append len(potions) - left to the result.

  • @israaezzat2353
    @israaezzat2353 Před rokem

    I'm so glad for those daily questions you solve .Keep it please .

  • @levimatheri7682
    @levimatheri7682 Před 4 měsíci +1

    This is the kind of question you hope you'll be asked at an interview, and not some obscure hard problem

  • @tg-shyam2887
    @tg-shyam2887 Před rokem +1

    Once again we welcome you back!!!!

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

    You can count pairs , with this formula as well -> count += (r - mid + 1)

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

    Actually, we don't need the idx, given the example in the video, {1, 2, 2, 2, 4}, the spell is 5, success is 10, and the last position for l is 1, which can just be used for counting the success, len - l is the result, this applies to any other cases as well. Please correct me if I was wrong.

  • @mohanadfteha4578
    @mohanadfteha4578 Před rokem

    Thank you!
    NOTE: you can just use the left pointer instead of the idx variable

  • @vijayjagan8198
    @vijayjagan8198 Před rokem +1

    Please cover before Daily challenge also, scramble strings and pizza sum
    This sum is pretty easy.

  • @datopotatogames6885
    @datopotatogames6885 Před rokem

    Blessed with another video from neetcode

  • @uptwist2260
    @uptwist2260 Před rokem

    Thanks for the daily

  • @rajat_171
    @rajat_171 Před rokem

    Amazing Explanation................

  • @samcarter8828
    @samcarter8828 Před rokem +1

    You can use l instead of idx

  • @krateskim4169
    @krateskim4169 Před rokem

    Thank you so much

  • @fighterdse3589
    @fighterdse3589 Před rokem +1

    Little reminder: nlogm + mlogm = (n+m)(logm), instead of n + m(logm). Anyway, you are awesome!🥰

  • @user-il1jp7ym9i
    @user-il1jp7ym9i Před rokem

    Can you please upload a video for solving the problem "number of ways of cutting a pizza"?

  • @shatakshivishnoi916
    @shatakshivishnoi916 Před rokem

    thanyou for explaination

  • @samarthtandale9121
    @samarthtandale9121 Před rokem

    Heyy, I follow your solutions regularly ... mainly because they are most intuitive and easy to understand! But why didn't you upload the solution for leetcode daily challenge of 31st march: number of ways of cutting pizza ... It was a very beautiful question!

  • @nizarkadri3109
    @nizarkadri3109 Před rokem +1

    that bisect method is crazy in python!!

    • @NeetCodeIO
      @NeetCodeIO  Před rokem +3

      Yeah it def is, but almost feels like cheating.. I think for this problem in an interview, writing out the binary search would be better, but depends on the interviewer

    • @nizarkadri3109
      @nizarkadri3109 Před rokem

      @@NeetCodeIO you are right, it does feel like cheating but might impress the interviewer that you know something which he doesn't

  • @user-gg7yj4wg4s
    @user-gg7yj4wg4s Před rokem

    thx, bro
    this was very helpful. esspecialy how you explained the algo and also gives the BigO notation

  • @martinzeng580
    @martinzeng580 Před rokem

    missed you

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

    U a Wizard God

  • @vixguy
    @vixguy Před rokem

    why is the leetcode syntax coloring going a little crazy? I dont like it lol

  • @kevf1029
    @kevf1029 Před rokem +1

    I sell my wife so I can upgrade my computer to do more leetcodes

  • @RajeshSingh-zc6ct
    @RajeshSingh-zc6ct Před rokem

    Don't know why it showing TLE at my end

    • @cosepeter2197
      @cosepeter2197 Před rokem

      in line 15 you might have missed the = sign

  • @aianaabdyrakhmanova5439

    god bless you

  • @lycan2494
    @lycan2494 Před rokem

    thank you for this! :D helped a lot

  • @adityamwagh
    @adityamwagh Před rokem

    First

  • @roywastaken
    @roywastaken Před rokem

    maestro