K Inverse Pairs Array - Leetcode 629 - Python
Vložit
- čas přidán 27. 07. 2024
- 🚀 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
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. CZcams 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!!
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~ 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!
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! This was one of THE problems I was not able to get my head around! Thanks for all the good work!
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.
Neato!! As far as knowledge is gained and content is understandable, doesn't matter how long the video is .. Thanks for the video
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
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! thanks for the explanation, I always jump to your channel whenever there's a Hard problem.
Thank you for this, definitely a hard problem
neato! thanks man.. you really are making stuff easier for beginners
Neato! Needed you to come and save the day
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 !
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.
finally after spent hours i cant able to do
after seing sliding window pattren + dp i came up with solution within seconds
Neato!!
Just looking at a 10 pages long editorial gave me headache.
Thanks for saving me.
Neato.
I went with the DP solution at first .Sliding window optimization is great
Neato! Love the videos as well as the idea behind the different solutions :)
neato! thanks for going through all the steps to solve the problem
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! You explained things very easily. Great approach.
Thank you for such 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. 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.
total includes prev[N-K] so why is the result when subtracting negative?
@@binh-nguyen-dbecause of calculating the total % MOD and the underflow of int type.
THANK YOU for this - I could not understand why one of my test cases was an extremely negative number
Neato!!
The way you approach the solution step by step ❤️
Neato lol
I always watch the whole thing because of your explanations and the path you show to actually get to the solution
neato, first time in a while just silencing everything and looking at the in depth solution
Neato!! loved the optimization part
Neato! I actually didn't grasp everything you just told, maybe i need to review dp again , anyways great teaching as always
Thank you for clear explanations!
Neato~Your videos have always helped me so much when practicing the problems!
Neato!! Excellent Explanation!! I like to watch your videos always whether I know the solution or not.
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
Always watch till the end because no matter how complicated, this guy can make it simpler only a little concentration is needed.
this video is amazing, really clever solution!
Neato! Loved your solution.
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!
@NeetCodeIO you left a condition while subtracting from the total for C++ and Java users:
if(total
Can you explain what does this do?
I was getting the runtime error: signed integer overflow: -1533914095 + -675939082 cannot be represented in type 'int'
Thanks for the soln Neato!
Genius solution with amazing explanation!
super explanation neato!!!
Neato! Well explained as always ❤
We need another algorithms super hard course in the platform!!
neato!! it was a tough problem, but learned a lot, thanks
neato! this is the hardest problem i've encountered in daily challenge.
Amazing explanation !! Neato 😆😆
Neato
Thank you for your videos!
Neato !! Great explanation
great explanation!
superb explanation and approach
Wow thank you so much neetio :)!
Neato. Great explanation, but what a wild problem. I hope to never get asked to optimize a DP to this point....
neato!! Great explanation
Neato! Definitely a hard problem
This is ridiculously hard. I cannot imagine someone coming up with this solution during the interview.
Best explication.
neato ! you are the GOAT. Thanks a lot.
This came on yesterday's Daily question!, neatoo
Neato, you are the best, thank you😊
ngl but this is one of the best questions in Leetcode and Neetcode has nailed it down with yet another legendary video (neato)
neato!! big brain solutions ❤
neato!!!! Another great video
neato! I am a beginner so it was very hard for me but still, I watched the full video and learned a lot.
neeto~ Thanks for the smooth explanation!
Neato ~ This is a definitely a big brain problem.
super neatooo!🔥
Neato! Head hurting right now 😨
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.
Neato, really a HARD one!
Perfect tutorial🤍
neato! Really helpful video, as always. Save me a lot of time, thanks.
neato! this was really an interesting problem
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!!! How long did it take for you to get to the optimal solution on your own? Just curious.
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
Hey neato it was a great video with an awesome explanation
We love you neetcode
neato👍👍
Thanks BRO
at 12:28, why are donig res = res+ (count(n-1,k-1))?
Neato 🎉
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
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?
Neato!
Neato!!
neato; Thanks!
neato 🎉
Neato. Nice explanation. But have to come back to it later ;(
damn, i solved daily problems everyday and your video is always the highlight of my day
neato!!
Neato !!!