neato!! learned a lot from how you gradually get the final solution.
@wintersol992111 ай бұрын
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
@BlunderArmour11 ай бұрын
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.
@walkastray00711 ай бұрын
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
@simonvutov757511 ай бұрын
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!!
@jonathanlo102611 ай бұрын
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!
@shashwatkumar307911 ай бұрын
Always watch till the end because no matter how complicated, this guy can make it simpler only a little concentration is needed.
@anthonyleong423811 ай бұрын
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.
@surajvalluru11 ай бұрын
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.
@hamirmahal11 ай бұрын
Neat-o! I appreciate the longer length videos. I think they're very helpful. Thank you for making them.
@satyamjha6811 ай бұрын
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!!
@rahulsbhatt11 ай бұрын
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!
@tenthlegionstudios134311 ай бұрын
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!
@SanketBhat711 ай бұрын
Neato!! As far as knowledge is gained and content is understandable, doesn't matter how long the video is .. Thanks for the video
@EvanKendrick-d8h11 ай бұрын
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.
@sachinsinghbhadoriya952311 ай бұрын
Neato! This was one of THE problems I was not able to get my head around! Thanks for all the good work!
@LakshyaSethi-g7w11 ай бұрын
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!
@yaswanthkosuru11 ай бұрын
finally after spent hours i cant able to do after seing sliding window pattren + dp i came up with solution within seconds
@pritz911 ай бұрын
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 !
@krishsharvesh808211 ай бұрын
Neato! I actually didn't grasp everything you just told, maybe i need to review dp again , anyways great teaching as always
@mire523411 ай бұрын
This is ridiculously hard. I cannot imagine someone coming up with this solution during the interview.
@tkncompsci935311 ай бұрын
Neato!! Excellent Explanation!! I like to watch your videos always whether I know the solution or not.
@weronikalinda491711 ай бұрын
Neato lol I always watch the whole thing because of your explanations and the path you show to actually get to the solution
@gitarowydominik11 ай бұрын
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-d11 ай бұрын
total includes prev[N-K] so why is the result when subtracting negative?
@gitarowydominik11 ай бұрын
@@binh-nguyen-dbecause of calculating the total % MOD and the underflow of int type.
@StephanieJohnston-rt7rq7 ай бұрын
THANK YOU for this - I could not understand why one of my test cases was an extremely negative number
@michael._.11 ай бұрын
ngl but this is one of the best questions in Leetcode and Neetcode has nailed it down with yet another legendary video (neato)
@radon389411 ай бұрын
Another excellent video, appreciate the time to explain your thought process!
@robertyamasaki180711 ай бұрын
neato, first time in a while just silencing everything and looking at the in depth solution
@PabloElBlanco11 ай бұрын
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!
@aniketpatel865511 ай бұрын
Neato! You explained things very easily. Great approach. Thank you for such solution
@evanhuang75611 ай бұрын
Neato. I went with the DP solution at first .Sliding window optimization is great
@yashraj300511 ай бұрын
We love you neetcode
@abhishekkaintura639811 ай бұрын
the way you explain the problem is really appreciable
@saminhasan8711 ай бұрын
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.
@jasonust38 ай бұрын
Genius solution with amazing explanation!
@sankalpchordia524511 ай бұрын
We need another algorithms super hard course in the platform!!
@triputrafauzanhradji800511 ай бұрын
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.
@rohanthakur915911 ай бұрын
Neato!! Just looking at a 10 pages long editorial gave me headache. Thanks for saving me.
@hackytech749411 ай бұрын
Neato! Well explained as always ❤
@diegobarbieri780411 ай бұрын
this video is amazing, really clever solution!
@ahasunos591411 ай бұрын
Neato!! The way you approach the solution step by step ❤️
@meylyssa366611 ай бұрын
Thank you for clear explanations!
@विक्रमचौहान-द2थ11 ай бұрын
neato! I am a beginner so it was very hard for me but still, I watched the full video and learned a lot.
@lawlesslotus11 ай бұрын
neato! thanks for the explanation, I always jump to your channel whenever there's a Hard problem.
@AMakYu11 ай бұрын
Neato. Great explanation, but what a wild problem. I hope to never get asked to optimize a DP to this point....
@ridamkrishna11 ай бұрын
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
@varunpalsingh382211 ай бұрын
neato!! it was a tough problem, but learned a lot, thanks
@squid8420211 ай бұрын
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
@sidreddy703011 ай бұрын
Neato! Needed you to come and save the day
@ameetasom83211 ай бұрын
Neato!! loved the optimization part
@EduarteBDO11 ай бұрын
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
@phuongnguyenhuynhanh746211 ай бұрын
damn, i solved daily problems everyday and your video is always the highlight of my day
@anirbansarkar418911 ай бұрын
superb explanation and approach
@jacquelinejan589811 ай бұрын
Neato~Your videos have always helped me so much when practicing the problems!
@ElliuHuang11 ай бұрын
neato! thanks for going through all the steps to solve the problem
@jiteshpahwa26611 ай бұрын
@NeetCodeIO you left a condition while subtracting from the total for C++ and Java users: if(total
@kartik696811 ай бұрын
Can you explain what does this do? I was getting the runtime error: signed integer overflow: -1533914095 + -675939082 cannot be represented in type 'int'
@tizekodnoon830511 ай бұрын
Neato! Head hurting right now 😨
@piyushgupta721011 ай бұрын
neato! thanks man.. you really are making stuff easier for beginners
@timlu47345 ай бұрын
neato! Really helpful video, as always. Save me a lot of time, thanks.
@blurryfca311 ай бұрын
This came on yesterday's Daily question!, neatoo
@qboff446811 ай бұрын
Neato, you are the best, thank you😊
@ngoquangtrung23411 ай бұрын
Best explication.
@virgil24611 ай бұрын
neeto~ Thanks for the smooth explanation!
@walkastray00711 ай бұрын
Neeto. I didn't make it to the solution, but I did think about the brute force one.
@leemin-gyu323611 ай бұрын
Neato! Love the videos as well as the idea behind the different solutions :)
@aswinnath858011 ай бұрын
neato! this is the hardest problem i've encountered in daily challenge.
@aryanikale718711 ай бұрын
Thank you for this, definitely a hard problem
@johnj1715 ай бұрын
God Father !!! I have made the video so farr you are amazing the king GODFATHER!!! love you content
@estifanosbireda189211 ай бұрын
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?
@mohitkanodia538811 ай бұрын
Neato !! Great explanation
@VanjeAv10 ай бұрын
Wow thank you so much neetio :)!
@nishantketu204011 ай бұрын
neato👍👍
@sprajosh11 ай бұрын
Neato ~ This is a definitely a big brain problem.
@arturremizov929611 ай бұрын
Neato Thank you for your videos!
@ajaykumargogineni339111 ай бұрын
neato!! Great explanation
@VasudevaK11 ай бұрын
Perfect tutorial🤍
@rileysikes928511 ай бұрын
neato!!!! Another great video
@Kugelblitz2b9 ай бұрын
neato 😭🤓
@MrKB_SSJ211 ай бұрын
25:40 DAMNNNNN NOTICED THE OPTIMIZATION. IMAGINE SOMEONE ASKS THIS IN THE INTERVIEW MANNN
@krateskim416911 ай бұрын
Hey neato it was a great video with an awesome explanation
@swanv95111 ай бұрын
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)
@art4eigen9311 ай бұрын
neato! but repeating the whole again, and again.
@sunilswizy823311 ай бұрын
super explanation neato!!!
@nikhil1990298 ай бұрын
at 12:28, why are donig res = res+ (count(n-1,k-1))?
@rikthecuber11 ай бұрын
Thanks for the soln Neato!
@aswathchandrasekar291711 ай бұрын
Neato. Nice explanation. But have to come back to it later ;(
@AbdulrahmanEgy11 ай бұрын
super neatooo!🔥
@hikmetdemir103211 ай бұрын
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
@MP-ny3ep11 ай бұрын
Amazing explanation !! Neato 😆😆
@prateekgupta141711 ай бұрын
Neato! Definitely a hard problem
@yuxiangwang96311 ай бұрын
Neato, really a HARD one!
@bhavyagautam803611 ай бұрын
Neato! Loved your solution.
@ronbuchanan543211 ай бұрын
Kudos to Neato! (don't you have video statistics though? haha)
@aniruddhachaki716511 ай бұрын
neato! it's 12:48 am here!
@ankurbose767211 ай бұрын
Neato!!! How long did it take for you to get to the optimal solution on your own? Just curious.
@nooobody275111 ай бұрын
neato ! you are the GOAT. Thanks a lot.
@Cheng-K11 ай бұрын
Neato! 🧠
@insaeq11 ай бұрын
great explanation!
@AdenGolden11 ай бұрын
number of permutations of length n with k inversions is the same as the number of permutations of length n with a major index equal to k. class Solution: def kInversePairs(self, n: int, k: int) -> int: MOD = 10 ** 9 + 7 dp = [[0] * (k + 1) for _ in range(n + 1)] dp[1][0] = 1 for i in range(2, n + 1): cumulative = 0 for j in range(k + 1): cumulative += dp[i - 1][j] if j >= i: cumulative -= dp[i - 1][j - i] dp[i][j] = cumulative % MOD return dp[n][k]
@Kaviarasu_NS11 ай бұрын
neato!! big brain solutions ❤
@erminiottone11 ай бұрын
I passed the OJ with the first recursive solution in C++ with TC O(n*k^2) 😅