K Inverse Pairs Array - Leetcode 629 - Python
🚀 neetcode.io/ - A better way to prepare for Coding Interviews
🧑💼 LinkedIn: / navdeep-singh-3aaa14161
🐦 Twitter: / neetcode1
⭐ BLIND-75 PLAYLIST: • Two Sum - Leetcode 1 -...
Problem Link: leetcode.com/problems/k-inver...
0:00 - Read the problem
0:39 - Recursive explanation
10:36 - Recursive coding
13:39 - DP explanation
20:38 - DP coding
24:47 - Sliding Window explanation
27:24 - Sliding Window coding
leetcode 629
#neetcode #leetcode #python
Пікірлер: 341
neato!! learned a lot from how you gradually get the final solution.
I don't know how you do it, put you always explain just the best and the simplest way possible. KZread 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
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.
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!!
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!
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
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!
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.
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!!
Neato! This was one of THE problems I was not able to get my head around! Thanks for all the good work!
finally after spent hours i cant able to do after seing sliding window pattren + dp i came up with solution within seconds
Neato!! As far as knowledge is gained and content is understandable, doesn't matter how long the video is .. Thanks for the video
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!
Neat-o! I appreciate the longer length videos. I think they're very helpful. Thank you for making them.
Another excellent video, appreciate the time to explain your thought process!
the way you explain the problem is really appreciable
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 !
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.
neato! thanks for the explanation, I always jump to your channel whenever there's a Hard problem.
neato! thanks man.. you really are making stuff easier for beginners
Neato. I went with the DP solution at first .Sliding window optimization is great
Neato! Needed you to come and save the day
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!
Neato!! Just looking at a 10 pages long editorial gave me headache. Thanks for saving me.
Thank you for this, definitely a hard problem
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.
Always watch till the end because no matter how complicated, this guy can make it simpler only a little concentration is needed.
neato! thanks for going through all the steps to solve the problem
Neato!! The way you approach the solution step by step ❤️
Neato! Love the videos as well as the idea behind the different solutions :)
Neato! You explained things very easily. Great approach. Thank you for such solution
neato, first time in a while just silencing everything and looking at the in depth solution
Neato lol I always watch the whole thing because of your explanations and the path you show to actually get to the solution
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.
Neato! I actually didn't grasp everything you just told, maybe i need to review dp again , anyways great teaching as always
Neato!! loved the optimization part
Neato~Your videos have always helped me so much when practicing the problems!
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
Thank you for clear explanations!
Neato!! Excellent Explanation!! I like to watch your videos always whether I know the solution or not.
this video is amazing, really clever solution!
Genius solution with amazing explanation!
Neato! Well explained as always ❤
neato! this is the hardest problem i've encountered in daily challenge.
neato!! it was a tough problem, but learned a lot, thanks
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!
Neato! Loved your solution.
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
5 ай бұрын
total includes prev[N-K] so why is the result when subtracting negative?
@gitarowydominik
5 ай бұрын
@@binh-nguyen-dbecause of calculating the total % MOD and the underflow of int type.
@StephanieJohnston-rt7rq
2 ай бұрын
THANK YOU for this - I could not understand why one of my test cases was an extremely negative number
Wow thank you so much neetio :)!
This is ridiculously hard. I cannot imagine someone coming up with this solution during the interview.
We need another algorithms super hard course in the platform!!
Neato Thank you for your videos!
Neato. Great explanation, but what a wild problem. I hope to never get asked to optimize a DP to this point....
Thanks for the soln Neato!
Neato !! Great explanation
superb explanation and approach
ngl but this is one of the best questions in Leetcode and Neetcode has nailed it down with yet another legendary video (neato)
super explanation neato!!!
Neato ~ This is a definitely a big brain problem.
neeto~ Thanks for the smooth explanation!
Amazing explanation !! Neato 😆😆
Neato! Definitely a hard problem
Neato, you are the best, thank you😊
neato!! Great explanation
neato ! you are the GOAT. Thanks a lot.
neato!!!! Another great video
Best explication.
This came on yesterday's Daily question!, neatoo
Neato! Head hurting right now 😨
@NeetCodeIO you left a condition while subtracting from the total for C++ and Java users: if(total
@kartik6968
5 ай бұрын
Can you explain what does this do? I was getting the runtime error: signed integer overflow: -1533914095 + -675939082 cannot be represented in type 'int'
great explanation!
Neato, really a HARD one!
neato! I am a beginner so it was very hard for me but still, I watched the full video and learned a lot.
neato!! big brain solutions ❤
super neatooo!🔥
neato! this was really an interesting problem
We love you neetcode
Perfect tutorial🤍
Hey neato it was a great video with an awesome explanation
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
Neato! 🧠
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
damn, i solved daily problems everyday and your video is always the highlight of my day
Neato! ❤
neato; Thanks!
Thanks BRO
Neato. Nice explanation. But have to come back to it later ;(
neato 🎉
neato👍👍
Neato!
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.
certified neato!!
neato! but repeating the whole again, and again.
neato!!
Neato 🎉
Neato!!
Neato!!! How long did it take for you to get to the optimal solution on your own? Just curious.
neato 😭🤓
neato!
Neato !!!