Successful Pairs of Spells and Potions - Leetcode 2300 - Python

  Рет қаралды 12,308

NeetCodeIO

NeetCodeIO

Күн бұрын

🚀 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

Пікірлер: 38
@tanish5662
@tanish5662 Жыл бұрын
missed you more than my girlfriend, thanks for being in my life
@Tehnubwaffle
@Tehnubwaffle 8 ай бұрын
A girlfriend has too many edge cases
@MP-ny3ep
@MP-ny3ep Жыл бұрын
Thank you ! Please keep doing the daily leetcode questions. They're very helpful/motivating,
@asmahamdym
@asmahamdym Жыл бұрын
when you do the leetcode daily questions I feel like I have backup😃 Thanks for that
@deepakprasanna6798
@deepakprasanna6798 Жыл бұрын
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 11 ай бұрын
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!!!!!!
@levimatheri7682
@levimatheri7682 4 ай бұрын
This is the kind of question you hope you'll be asked at an interview, and not some obscure hard problem
@bhushanmahajan2150
@bhushanmahajan2150 Жыл бұрын
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 Жыл бұрын
I'm so glad for those daily questions you solve .Keep it please .
@tg-shyam2887
@tg-shyam2887 Жыл бұрын
Once again we welcome you back!!!!
@datopotatogames6885
@datopotatogames6885 Жыл бұрын
Blessed with another video from neetcode
@uptwist2260
@uptwist2260 Жыл бұрын
Thanks for the daily
@dingus2332
@dingus2332 8 ай бұрын
You can count pairs , with this formula as well -> count += (r - mid + 1)
@mohanadfteha4578
@mohanadfteha4578 Жыл бұрын
Thank you! NOTE: you can just use the left pointer instead of the idx variable
@rajat_171
@rajat_171 Жыл бұрын
Amazing Explanation................
@vijayjagan8198
@vijayjagan8198 Жыл бұрын
Please cover before Daily challenge also, scramble strings and pizza sum This sum is pretty easy.
@krateskim4169
@krateskim4169 Жыл бұрын
Thank you so much
@shatakshivishnoi916
@shatakshivishnoi916 Жыл бұрын
thanyou for explaination
@samcarter8828
@samcarter8828 Жыл бұрын
You can use l instead of idx
@rowanus116
@rowanus116 Ай бұрын
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.
@fighterdse3589
@fighterdse3589 Жыл бұрын
Little reminder: nlogm + mlogm = (n+m)(logm), instead of n + m(logm). Anyway, you are awesome!🥰
@user-il1jp7ym9i
@user-il1jp7ym9i Жыл бұрын
Can you please upload a video for solving the problem "number of ways of cutting a pizza"?
@nizarkadri3109
@nizarkadri3109 Жыл бұрын
that bisect method is crazy in python!!
@NeetCodeIO
@NeetCodeIO Жыл бұрын
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 Жыл бұрын
@@NeetCodeIO you are right, it does feel like cheating but might impress the interviewer that you know something which he doesn't
@samarthtandale9121
@samarthtandale9121 Жыл бұрын
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!
@lycan2494
@lycan2494 Жыл бұрын
thank you for this! :D helped a lot
@martinzeng580
@martinzeng580 Жыл бұрын
missed you
@user-gg7yj4wg4s
@user-gg7yj4wg4s Жыл бұрын
thx, bro this was very helpful. esspecialy how you explained the algo and also gives the BigO notation
@edwardteach2
@edwardteach2 Ай бұрын
U a Wizard God
@vixguy
@vixguy Жыл бұрын
why is the leetcode syntax coloring going a little crazy? I dont like it lol
@kevf1029
@kevf1029 Жыл бұрын
I sell my wife so I can upgrade my computer to do more leetcodes
@RajeshSingh-zc6ct
@RajeshSingh-zc6ct Жыл бұрын
Don't know why it showing TLE at my end
@cosepeter2197
@cosepeter2197 Жыл бұрын
in line 15 you might have missed the = sign
@adityamwagh
@adityamwagh Жыл бұрын
First
@aianaabdyrakhmanova5439
@aianaabdyrakhmanova5439 Жыл бұрын
god bless you
@roywastaken
@roywastaken Жыл бұрын
maestro
Dota2 Senate - Leetcode 649 - Python
14:48
NeetCodeIO
Рет қаралды 19 М.
Capacity to Ship Packages - Leetcode 1011 - Python
12:25
NeetCodeIO
Рет қаралды 19 М.
Heartwarming moment as priest rescues ceremony with kindness #shorts
00:33
Fabiosa Best Lifehacks
Рет қаралды 38 МЛН
Nastya and SeanDoesMagic
00:16
Nastya
Рет қаралды 15 МЛН
What it feels like cleaning up after a toddler.
00:40
Daniel LaBelle
Рет қаралды 73 МЛН
Number of Enclaves - Leetcode 1020 - Python
11:39
NeetCodeIO
Рет қаралды 7 М.
5 Useful F-String Tricks In Python
10:02
Indently
Рет қаралды 281 М.
Check Completeness of a Binary Tree - Leetcode 958 - Python
7:57
por que parei de usar Vim depois de 2 anos de uso
14:44
Lucas Montano
Рет қаралды 8 М.
Arranging Coins - Leetcode 441 - Python
12:53
NeetCode
Рет қаралды 34 М.
I gave 127 interviews. Top 5 Algorithms they asked me.
8:36
Sahil & Sarra
Рет қаралды 625 М.
Heartwarming moment as priest rescues ceremony with kindness #shorts
00:33
Fabiosa Best Lifehacks
Рет қаралды 38 МЛН