The way you make hard problems look so easy is amazing, thanks!
@rommeltito1232 жыл бұрын
10+ years coding and I still enjoy watching ur videos.
@dj1984x9 ай бұрын
the first hard problem i've gotten without first viewing the solution ... feels good & hard work + Neetcode videos pays off :)
@freshlyminted69992 жыл бұрын
My code was kinda the same, but yours is a lot cleaner. That's something I really appreciate. Thanks for the great content. :)
@shaikadam18283 ай бұрын
dude i got an approach before but i wasn't sure of its implementation when i saw urs it's not totally same but the iteration part was missing in my approach now i got that thx dude appreciated it
@mingchenma46792 жыл бұрын
Thanks for all your videos, they helped me so much. I landed my dream job. Please keep up ur channel! Merry Christmas!
@sauravchandra10 Жыл бұрын
When you said it is a doable hard, I figured lets try this till I get it accepted and after a bit of back and forth, I was able to get my code accepted. This is my C++ implementation: class Solution { public: int n,m; int drow[4]={-1,0,1,0}, dcol[4]={0,1,0,-1}; bool isValid(int &row, int &col){ return row>=0 && row=0 && col
@girirajrdx72772 жыл бұрын
Pls keep uploading....I am learning a lot. You are my guide
@ngneerin2 жыл бұрын
Beautiful solution. Looking forward to more such videos
@minciNashu2 жыл бұрын
this one made me feel good about myself, cuz I knew right away it's a grid DFS with memoized storage
@andrewyuan78812 жыл бұрын
Great problem and explanation
@Septix2 жыл бұрын
Neet what are you thoughts on spaced repetition? Not writing the entire solution and memorizing it... instead, it would be cards in front: statement of the problem, back: Pattern (two pointers, DFS, etc) and any comments, maybe even drawings. Ideally this would help with just pattern recognition over time but wondering if you think it would be useless/ too much memorizing. Would use Anki for reference, thoughts?
@dj1984x9 ай бұрын
i think it's a good idea, spaced repetition is shown to be very effective for memorization (that's if you're trying to memorize the blind 75/neetcode150, etc.) even better though is simple practice problem solving, so you can solve new problems the first time working through them. spaced repetition could probably help in learning patterns for this
@rezajeffrey79702 жыл бұрын
I literally search all the youtube I didnt find a guy explaining better than you Keep on..
@dk20can862 жыл бұрын
If you want a bottom up DP solution, you can sort the values of the matrix in descending order (i used a heap, but a sorted array would work too) and process them in that order. You'll be guaranteed to have already calculated the LIPs of your larger neighbours as you visit each element, so you don't need DFS/recursion. Same time and space complexity of course.
@mubarizsaeed187 Жыл бұрын
what do u mean u dont need dfs? how would u find the path tho
@xiaohuisun Жыл бұрын
that's my first thought as well. (m*n)(log(m*n)) for sorting I guess
@KnuthMorrisАй бұрын
Brilliant solution.
@sakethkumarpeddi20897 ай бұрын
i think we can directly write this statement right. res = 1+max(dfs(r+1,c,matrix[r][c]),dfs(r-1,c,matrix[r][c]),dfs(r,c+1,matrix[r][c]),dfs(r,c-1,matrix[r][c])) instead of those 5 lines of code??
@buttofthejoke7 ай бұрын
I think so too. we are calculating max of res again and again, but we can do max ((left, right, top, bottom) + 1)
@sakethkumarpeddi20897 ай бұрын
@@buttofthejoke yes.. exactly
@hwang16075 ай бұрын
yes but its more difficult to read
@vincentlius15692 жыл бұрын
very clean code !! like the way you use dictionary as cache
@jamespolemeni5475 Жыл бұрын
The Gold Standard of Leetcode tutorials
@BeingAsh222 жыл бұрын
This was the best explanation, you made the problem so easy. Thank you!
@hgk70272 жыл бұрын
Best Leetcode KZbin channel!
@NeetCode2 жыл бұрын
Python Code: github.com/neetcode-gh/leetcode/blob/main/329-Longest-Increasing-Path-in-a-Matrix.py Java Code (courtesy of a viewer - ndesai15): github.com/ndesai15/coding-java/blob/master/src/com/coding/patterns/dynamicprogramming/memoize/LongestIncreasingPath.java
@aryanyadav3926 Жыл бұрын
Brilliant explanation!
@AryanSingh-zv5ch Жыл бұрын
Thanks man any tips to approach problem like u do?
@jitbanerjee6875 Жыл бұрын
Small addition, implement backtracking to slightly improve the running time. P.S. Solved this problem on my own in just 20 minutes. Can't stop thanking you.
@NhanSleeptight2 жыл бұрын
Merry Christmas, let do some neetcode today
@ronniey42319 ай бұрын
Awesome as always ❤❤❤❤
@bhuvneshsingh33472 жыл бұрын
Thanks!
@NeetCode2 жыл бұрын
Thank you so much!
@nishantingle14382 жыл бұрын
Graph with Dynamic Programming
@henryCcc86142 жыл бұрын
= Weapon of Mass Destruction
@peeckle16572 жыл бұрын
Great Solution!!
@nuamaaniqbal63732 жыл бұрын
The problem was nicely broken down!
@Ragdoll333-q5l2 жыл бұрын
Hi Neetcode! Could you upload something in terms of bit masking? like 1915?
@matthewzhang73302 жыл бұрын
Thanks for the solution!
@matthewzhang73302 жыл бұрын
Would you mind making a video for 68: Text Justification?
@ram_pande80392 жыл бұрын
Very clean code ❤️
@HalfJoked Жыл бұрын
Amazing, thanks so much. I want to just add, I think these few lines look a bit cleaner than the 4 repeated lines of reassigning the 'res' variable. directions = [[1,0], [0,1], [-1,0], [0,-1]] for rowDir, colDir in directions: res = max(res, 1 + backtrack(row+rowDir, col+colDir, cur))
@georgegeorge5812 жыл бұрын
Really helpful!!
@paraskumar6932 жыл бұрын
it should have easy tag
@vadimkokielov21732 жыл бұрын
A bit of trivia here. I just read the section on DFS in Intro to Algorithms (en.wikipedia.org/wiki/Introduction_to_Algorithms ) The theoretical kind of DFS they define there is actually always run on all the vertices of the graph. So anyone who read that book and was paying attention -- I wasn't :) :D -- would have this idea cold.
@romo119 Жыл бұрын
Seems like this shouldn't really be labelled "hard". Some of the graph dfs medium problems are much harder
@dj1984x9 ай бұрын
agreed, this was relatively simple for a graph problem, just need to implement cache
@hanjiang98882 жыл бұрын
thank you you made dp problems no longer unapproachable to me 😭
@user-gg1qc8ld5x2 жыл бұрын
Won’t the Error: List index out of range matrix[r][c]
@Eggleweb972 жыл бұрын
please make a video on LeetCode 1499. Max Value of Equation
@minato65362 жыл бұрын
How to calculate the number of longest path?
@tshotblue222 жыл бұрын
how come backtracking isn’t used here? from each point, isn’t it possible to have several valid paths, where one path is the longest?
@user-uc9dp1gh4d6 ай бұрын
If this matrix increased by 20% what is new marix
@senthilkumar52 жыл бұрын
Best!!!
@shavvasatya7131 Жыл бұрын
Is'nt not a hard.🤩
@priyanshudeep10082 жыл бұрын
Isn't this just dp??
@EduarteBDO7 ай бұрын
This is more like a medium problem. It's not hard
@AseshShrestha2 жыл бұрын
👏
@lakhbawa2 жыл бұрын
For god’s sake, pls start using simpler python(without syntax suger) or start using some other language such as Java, we are not here to learn python or see your language skills but program solving, i am referring your other video, cannot dare to watch this one bcoz I don’t wanna waste time learning python syntax, i am sorry if it looks rude
@NeetCode2 жыл бұрын
Not sure which video you're talking about, but there's nothing fancy in this code. The general ideas most of the time be easily translated between languages, and if you can't do that it's most likely that you don't understand the solution. Nothing related to the language. If anything, python is written like psuedo code, Java has so much boiler plate it makes things more complicated.
@mk17173n2 жыл бұрын
Typical Indian thinking he is smarter than people. If you dont like it in Python watch other videos. My primary language is JavaScript but i appreciate these videos.
@alokesh9852 жыл бұрын
@@NeetCode Please try and ignore these outlier comments. Most people love your Python solutions and I personally don't think your code can get any simpler! Please continue the great work!
@Ak-um1yg2 жыл бұрын
@@mk17173n was there any need to point out the nationality ?? Indians have the best brains .... I think you have some hatred / jealousy for Indian people
@Mr_corporate_gamer2 жыл бұрын
@@mk17173n yeh i am also using js and python can be read like English language and we can convert into any language we want. There is no fancy coding here