K Inverse Pairs Array - Leetcode 629 - Python

  Рет қаралды 17,287

NeetCodeIO

NeetCodeIO

Күн бұрын

Пікірлер: 351
@FirmamentTSW
@FirmamentTSW Жыл бұрын
neato!! learned a lot from how you gradually get the final solution.
@wintersol9921
@wintersol9921 Жыл бұрын
I don't know how you do it, put you always explain just the best and the simplest way possible. KZbin coding community is very lucky to have you, thanks man. I learned a lot from you, both how to code better and how to think to solve :D
@BlunderArmour
@BlunderArmour Жыл бұрын
Neato!!! Thank you for the explanation! This is definitely one of those problems where it's nearly impossible to come up with a solution in a time bound scenario.
@jonathanlo1026
@jonathanlo1026 Жыл бұрын
neato~ I actually watched a chinese youtuber solve this then came to see how you solved it, really loved the detailed explanation thank you, I got a lot from the first brute force dfs as well!
@walkastray007
@walkastray007 Жыл бұрын
Its kind of funny because the voice I use in my head for solving problems is your voice. Honestly this was a really well put together video. I really enjoyed how you go with brute force solutions and make optimizations one after the other. This really helps since it shows us how to get from a starting point to something finished
@simonvutov7575
@simonvutov7575 Жыл бұрын
Neato! This was super well explained and I felt like I came up with it myself and fully understood it by watching your thought process!!
@shashwatkumar3079
@shashwatkumar3079 Жыл бұрын
Always watch till the end because no matter how complicated, this guy can make it simpler only a little concentration is needed.
@sachinsinghbhadoriya9523
@sachinsinghbhadoriya9523 Жыл бұрын
Neato! This was one of THE problems I was not able to get my head around! Thanks for all the good work!
@rahulsbhatt
@rahulsbhatt Жыл бұрын
Thank you so much neato! You make these types of videos with so much clarity! It really helps me out a lot! Thank you so much for the daily content, man!
@anthonyleong4238
@anthonyleong4238 Жыл бұрын
I actually watch these. Algorithms are my passion, but I suck at interviews due to nerves. I am hoping that understanding these super hard problems conceptually by watching these videos can help me complete all medium/lower hard problems.
@satyamjha68
@satyamjha68 Жыл бұрын
Unable to solve on my own !!😭😭 I wrote O(n*n*k) solution but I wasn't able to write O(n*k) approach. Thanks for explanation!!
@hamirmahal
@hamirmahal Жыл бұрын
Neat-o! I appreciate the longer length videos. I think they're very helpful. Thank you for making them.
@SanketBhat7
@SanketBhat7 Жыл бұрын
Neato!! As far as knowledge is gained and content is understandable, doesn't matter how long the video is .. Thanks for the video
@LakshyaSethi-g7w
@LakshyaSethi-g7w Жыл бұрын
neato! never have i ever enjoyed watching a leetcode solution this much! The whole process helped me visualize not just this problem but how to approach a dp in general. Thank you!
@yaswanthkosuru
@yaswanthkosuru Жыл бұрын
finally after spent hours i cant able to do after seing sliding window pattren + dp i came up with solution within seconds
@EvanKendrick-d8h
@EvanKendrick-d8h Жыл бұрын
big NEATO! Your solutions have been tremendous! I've been learning to code on my own and reach for this channel whenever I get stumped on a leetcode problem.
@tenthlegionstudios1343
@tenthlegionstudios1343 Жыл бұрын
Made it to the end, spotted the optimization, but I failed to solve this on my first attempt. Also I have never seen an editorial with 7 solutions - this might be one of the longest editorials I have seen for a leetcode problem in terms of number of solutions. Great video! and clear explanation!
@surajvalluru
@surajvalluru Жыл бұрын
You can get recursive or bottom-up solution to get accepted by putting else break statement in for loop. We know that once k-i < 0 then for subsequent increments only consumes more time. Anyhow this is not optimised solution.
@sankalpchordia5245
@sankalpchordia5245 Жыл бұрын
We need another algorithms super hard course in the platform!!
@radon3894
@radon3894 Жыл бұрын
Another excellent video, appreciate the time to explain your thought process!
@weronikalinda4917
@weronikalinda4917 Жыл бұрын
Neato lol I always watch the whole thing because of your explanations and the path you show to actually get to the solution
@yashraj3005
@yashraj3005 Жыл бұрын
We love you neetcode
@gitarowydominik
@gitarowydominik Жыл бұрын
Neato. In Java the part "total -= prev[N - K]" won't work, as in some cases total can go negative. What is needed is "total = (total - prev[N - K] + MOD) % MOD;" or something similar, like adding MOD when total is negative.
@binh-nguyen-d
@binh-nguyen-d Жыл бұрын
total includes prev[N-K] so why is the result when subtracting negative?
@gitarowydominik
@gitarowydominik Жыл бұрын
@@binh-nguyen-dbecause of calculating the total % MOD and the underflow of int type.
@StephanieJohnston-rt7rq
@StephanieJohnston-rt7rq 8 ай бұрын
THANK YOU for this - I could not understand why one of my test cases was an extremely negative number
@hackytech7494
@hackytech7494 Жыл бұрын
Neato! Well explained as always ❤
@pritz9
@pritz9 Жыл бұрын
neato !! bang explanation :-)) This is my 778th problem on LeetCode, solved many dp hards, but could not solve this, was clueless for a long time ! Thank You !
@abhishekkaintura6398
@abhishekkaintura6398 Жыл бұрын
the way you explain the problem is really appreciable
@mire5234
@mire5234 Жыл бұрын
This is ridiculously hard. I cannot imagine someone coming up with this solution during the interview.
@krishsharvesh8082
@krishsharvesh8082 Жыл бұрын
Neato! I actually didn't grasp everything you just told, maybe i need to review dp again , anyways great teaching as always
@saminhasan87
@saminhasan87 Жыл бұрын
neato and neato again!! You have been superb. The way you solved the problem - from brute force to recursive dp to bottom-up dp to sliding window was just awesome. Thanks for the great effort.
@michael._.
@michael._. Жыл бұрын
ngl but this is one of the best questions in Leetcode and Neetcode has nailed it down with yet another legendary video (neato)
@tkncompsci9353
@tkncompsci9353 Жыл бұрын
Neato!! Excellent Explanation!! I like to watch your videos always whether I know the solution or not.
@robertyamasaki1807
@robertyamasaki1807 Жыл бұрын
neato, first time in a while just silencing everything and looking at the in depth solution
@PabloElBlanco
@PabloElBlanco Жыл бұрын
neato, going to have to rewatch this a few times to actually understand everything. interesting and tough problem, glad you made a video about it!
@evanhuang756
@evanhuang756 Жыл бұрын
Neato. I went with the DP solution at first .Sliding window optimization is great
@aniketpatel8655
@aniketpatel8655 Жыл бұрын
Neato! You explained things very easily. Great approach. Thank you for such solution
@sidreddy7030
@sidreddy7030 Жыл бұрын
Neato! Needed you to come and save the day
@jasonust3
@jasonust3 9 ай бұрын
Genius solution with amazing explanation!
@triputrafauzanhradji8005
@triputrafauzanhradji8005 Жыл бұрын
Neato!! I actually get lost since the DP Explanation segment but continued anyway because I was curious about the final solution, hoping I could gain some understanding after watching the whole thing.
@ahasunos5914
@ahasunos5914 Жыл бұрын
Neato!! The way you approach the solution step by step ❤️
@rohanthakur9159
@rohanthakur9159 Жыл бұрын
Neato!! Just looking at a 10 pages long editorial gave me headache. Thanks for saving me.
@nikhil199029
@nikhil199029 9 ай бұрын
at 12:28, why are donig res = res+ (count(n-1,k-1))?
@lawlesslotus
@lawlesslotus Жыл бұрын
neato! thanks for the explanation, I always jump to your channel whenever there's a Hard problem.
@piyushgupta7210
@piyushgupta7210 Жыл бұрын
neato! thanks man.. you really are making stuff easier for beginners
@ridamkrishna
@ridamkrishna Жыл бұрын
neato! i watched this video that far because i liked the way we can progress from a better solution to the best solution. thanks neetcode
@meylyssa3666
@meylyssa3666 Жыл бұрын
Thank you for clear explanations!
@johnj171
@johnj171 6 ай бұрын
Hey GodFather I love you video like every videos!! I have a doubt that at time 4:55 when we put 1 at the 0th index then we can have one inverse pair because 1,3,2 is something we can form then we have formed one index pair right? just a doubt But i understand the overall logic of the solution. Love you and your content GodFather Love you Neetcode!
@diegobarbieri7804
@diegobarbieri7804 Жыл бұрын
this video is amazing, really clever solution!
@विक्रमचौहान-द2थ
@विक्रमचौहान-द2थ Жыл бұрын
neato! I am a beginner so it was very hard for me but still, I watched the full video and learned a lot.
@aryanikale7187
@aryanikale7187 Жыл бұрын
Thank you for this, definitely a hard problem
@ElliuHuang
@ElliuHuang Жыл бұрын
neato! thanks for going through all the steps to solve the problem
@ameetasom832
@ameetasom832 Жыл бұрын
Neato!! loved the optimization part
@jacquelinejan5898
@jacquelinejan5898 Жыл бұрын
Neato~Your videos have always helped me so much when practicing the problems!
@varunpalsingh3822
@varunpalsingh3822 Жыл бұрын
neato!! it was a tough problem, but learned a lot, thanks
@squid84202
@squid84202 Жыл бұрын
Neato. It's crazy how much optimization you have to do for this one, but I guess that's why it's a hard problem lol
@ankurbose7672
@ankurbose7672 Жыл бұрын
Neato!!! How long did it take for you to get to the optimal solution on your own? Just curious.
@estifanosbireda1892
@estifanosbireda1892 Жыл бұрын
Great explanation for a Hard problem, I found it hard to get the recurrence relation even after I knew it's a dp problem. How did you get the intuition for using the relative ordering?
@jiteshpahwa266
@jiteshpahwa266 Жыл бұрын
@NeetCodeIO you left a condition while subtracting from the total for C++ and Java users: if(total
@kartik6968
@kartik6968 Жыл бұрын
Can you explain what does this do? I was getting the runtime error: signed integer overflow: -1533914095 + -675939082 cannot be represented in type 'int'
@leemin-gyu3236
@leemin-gyu3236 Жыл бұрын
Neato! Love the videos as well as the idea behind the different solutions :)
@EduarteBDO
@EduarteBDO Жыл бұрын
neato. As someone who couldn't figure even the dfs solution but watched everything this is super challenging probably impossible at my current level. I gess that I need to draw more and pratice more
@qboff4468
@qboff4468 Жыл бұрын
Neato, you are the best, thank you😊
@sprajosh
@sprajosh Жыл бұрын
Neato ~ This is a definitely a big brain problem.
@tizekodnoon8305
@tizekodnoon8305 Жыл бұрын
Neato! Head hurting right now 😨
@phuongnguyenhuynhanh7462
@phuongnguyenhuynhanh7462 Жыл бұрын
damn, i solved daily problems everyday and your video is always the highlight of my day
@blurryfca3
@blurryfca3 Жыл бұрын
This came on yesterday's Daily question!, neatoo
@timlu4734
@timlu4734 6 ай бұрын
neato! Really helpful video, as always. Save me a lot of time, thanks.
@AMakYu
@AMakYu Жыл бұрын
Neato. Great explanation, but what a wild problem. I hope to never get asked to optimize a DP to this point....
@anirbansarkar4189
@anirbansarkar4189 Жыл бұрын
superb explanation and approach
@aswinnath8580
@aswinnath8580 Жыл бұрын
neato! this is the hardest problem i've encountered in daily challenge.
@VasudevaK
@VasudevaK Жыл бұрын
Perfect tutorial🤍
@virgil246
@virgil246 Жыл бұрын
neeto~ Thanks for the smooth explanation!
@VanjeAv
@VanjeAv 11 ай бұрын
Wow thank you so much neetio :)!
@sunilswizy8233
@sunilswizy8233 Жыл бұрын
super explanation neato!!!
@existanz
@existanz Жыл бұрын
Hi, Neato. Is there a bug here? Such a case is possible when we subtract a number that we didn't take by MOD (on 12 line) and add with MOD (on 13). I think we need to move '% MOD' to 14 line.
@kartik6968
@kartik6968 Жыл бұрын
I was working in cpp and got this error: runtime error: signed integer overflow: -1533914095 + -675939082 cannot be represented in type 'int'
@nooobody2751
@nooobody2751 Жыл бұрын
neato ! you are the GOAT. Thanks a lot.
@arturremizov9296
@arturremizov9296 Жыл бұрын
Neato Thank you for your videos!
@bhavyagautam8036
@bhavyagautam8036 Жыл бұрын
Neato! Loved your solution.
@rikthecuber
@rikthecuber Жыл бұрын
Thanks for the soln Neato!
@prateekgupta1417
@prateekgupta1417 Жыл бұрын
Neato! Definitely a hard problem
@mohitkanodia5388
@mohitkanodia5388 Жыл бұрын
Neato !! Great explanation
@MP-ny3ep
@MP-ny3ep Жыл бұрын
Amazing explanation !! Neato 😆😆
@ngoquangtrung234
@ngoquangtrung234 Жыл бұрын
Best explication.
@MrKB_SSJ2
@MrKB_SSJ2 Жыл бұрын
25:40 DAMNNNNN NOTICED THE OPTIMIZATION. IMAGINE SOMEONE ASKS THIS IN THE INTERVIEW MANNN
@nishantketu2040
@nishantketu2040 Жыл бұрын
neato👍👍
@johnj171
@johnj171 6 ай бұрын
God Father !!! I have made the video so farr you are amazing the king GODFATHER!!! love you content
@Kaviarasu_S
@Kaviarasu_S Жыл бұрын
neato!! big brain solutions ❤
@krateskim4169
@krateskim4169 Жыл бұрын
Hey neato it was a great video with an awesome explanation
@AbdulrahmanEgy
@AbdulrahmanEgy Жыл бұрын
super neatooo!🔥
@walkastray007
@walkastray007 Жыл бұрын
Neeto. I didn't make it to the solution, but I did think about the brute force one.
@rileysikes9285
@rileysikes9285 Жыл бұрын
neato!!!! Another great video
@swanv951
@swanv951 Жыл бұрын
In the recursive solution, you only need to take i up to k and not up to n, since we know that (k-i) being negative is going to return 0 from recursive call. That makes it O(n*k*k) instead of O(n*n*k). It is still very bad bad but doesn't give TLE (at least in Java)
@ajaykumargogineni3391
@ajaykumargogineni3391 Жыл бұрын
neato!! Great explanation
@Cheng-K
@Cheng-K Жыл бұрын
Neato! 🧠
@yuxiangwang963
@yuxiangwang963 Жыл бұрын
Neato, really a HARD one!
@hikmetdemir1032
@hikmetdemir1032 Жыл бұрын
Could you please make an example training video for backtracking, graphs, tree and sliding window, starting from easy level to difficult level, just like you do for dynamic programming they are very instructive
@insaeq
@insaeq Жыл бұрын
great explanation!
@Kugelblitz2b
@Kugelblitz2b 10 ай бұрын
neato 😭🤓
@macwett
@macwett Жыл бұрын
neato! this was really an interesting problem
@aswathchandrasekar2917
@aswathchandrasekar2917 Жыл бұрын
Neato. Nice explanation. But have to come back to it later ;(
@sandrobatistasantos
@sandrobatistasantos Жыл бұрын
Neato! ❤
@art4eigen93
@art4eigen93 Жыл бұрын
neato! but repeating the whole again, and again.
Largest Divisible Subset - Leetcode 368 - Python
22:57
NeetCodeIO
Рет қаралды 17 М.
It’s all not real
00:15
V.A. show / Магика
Рет қаралды 20 МЛН
Cheerleader Transformation That Left Everyone Speechless! #shorts
00:27
Fabiosa Best Lifehacks
Рет қаралды 16 МЛН
Greatest Common Divisor Traversal - Leetcode 2709 - Python
24:30
Partition Array for Maximum Sum - Leetcode 1043 - Python
27:33
NeetCodeIO
Рет қаралды 19 М.
Find K-th Smallest Pair Distance - Leetcode 719 - Python
25:35
NeetCodeIO
Рет қаралды 16 М.
Minimum Falling Path Sum II - Leetcode 1289 - Python
31:44
NeetCodeIO
Рет қаралды 9 М.
Freedom Trail - Leetcode 514 - Python
25:18
NeetCodeIO
Рет қаралды 14 М.
Subarrays with K Different Integers - Leetcode 992 - Python
17:31
Student Attendance Record II - Leetcode 552 - Python
27:10
NeetCodeIO
Рет қаралды 10 М.
I gave 127 interviews. Top 5 Algorithms they asked me.
8:36
Sahil & Sarra
Рет қаралды 692 М.