The way to explain dp questions i haven't seen anyone on whole youtube breaking the dp questions in that way really your channel helped me a lot understanding dp easily. Thanks a lot !
I think you structured your video very very well and explained the concepts and solutions perfectly. Timestamps were also very helpful. Thank you for creating this.
@@nikoo28 just have one dp array of size equal to N, and initialise it with values in last row. Then perform bottom up approach. So our answer is in dp of 0.
When you were explaining the problem, you left explaining after 2 rows when things really started becoming tricky. You left at the point when it was most needed.
I discuss 2 approaches in the solution, a top-down and a bottom-up approach. Does that help? Can you tell me the timestamp at which you struggled? I can help more.
Brut force had better space complexity. public class TriangleMinPathSum { public int minimumTotal(List triangle) { return helper(triangle, 0, 0); } // Recursive helper method to find the minimum path sum private int helper(List triangle, int row, int col) { // Base case: if we reach the last row if (row == triangle.size() - 1) { return triangle.get(row).get(col); } // Recur to find the minimum path sum from the left and right children int leftPath = helper(triangle, row + 1, col); int rightPath = helper(triangle, row + 1, col + 1); // Current element + minimum of both paths return triangle.get(row).get(col) + Math.min(leftPath, rightPath); } }
The way to explain dp questions i haven't seen anyone on whole youtube breaking the dp questions in that way really your channel helped me a lot understanding dp easily.
Thanks a lot !
I think you structured your video very very well and explained the concepts and solutions perfectly. Timestamps were also very helpful. Thank you for creating this.
glad you feel that way
Thanks Sir , itni video's baad isme samjh aaya ....
theory-->Great explanation sir
feedback--> Explain code more clearly 🤗🤗
Appreciate your work! Most underrated channel though! Keep posting.
fingers crossed :)
Your explanation was top-notch !
Great explanation sir,pls bring on some most tricky interview questions frequently asked
Sure…i am adding new problems every week :)
the way that u explain with example it help a lot to understand
thanks sir
that is so nice of you
thank you so much man!
you explained so well
great explanation !!
Super explanation 😊
one vedio explains gist of dynamic programming and other concepts , thank you 😍
love the way you teach
Thank you annaa❤
Thank you very much, bhaiya.
Sir we can optimise the Space Complexity to O(N)
what will your approach be?
@@nikoo28 just have one dp array of size equal to N, and initialise it with values in last row. Then perform bottom up approach. So our answer is in dp of 0.
@@032_RishavDey that is indeed smart.. 😄
How
I was just curious and wanted to know if recursive approach would provide a better solution to this problem for bottom up approach
When you were explaining the problem, you left explaining after 2 rows when things really started becoming tricky. You left at the point when it was most needed.
I discuss 2 approaches in the solution, a top-down and a bottom-up approach. Does that help?
Can you tell me the timestamp at which you struggled? I can help more.
I would like to know how the top-bottom approach can be applied. I attempted to apply it but ran into difficulties. Could someone please assist me?
TC -> O(n^2)
S.C -> O(n^2)
Brut force had better space complexity.
public class TriangleMinPathSum {
public int minimumTotal(List triangle) {
return helper(triangle, 0, 0);
}
// Recursive helper method to find the minimum path sum
private int helper(List triangle, int row, int col) {
// Base case: if we reach the last row
if (row == triangle.size() - 1) {
return triangle.get(row).get(col);
}
// Recur to find the minimum path sum from the left and right children
int leftPath = helper(triangle, row + 1, col);
int rightPath = helper(triangle, row + 1, col + 1);
// Current element + minimum of both paths
return triangle.get(row).get(col) + Math.min(leftPath, rightPath);
}
}