This is the BEST explanation for this question on you tube.❤
@fine2981 Жыл бұрын
Wow thank you so much ....best explanation available on you tube for this question.
@saishanmukh38052 ай бұрын
This is such a neat explanation!
@antojoshwa9663 жыл бұрын
Great explanation . Deserve more subs
@mohakbansal58662 жыл бұрын
best solution keep making more videos
@TarunKumar-cn6in2 жыл бұрын
Best explanation 👍
@neerajmahapatra52392 жыл бұрын
Amazing explanation.. When I saw your video I checked my playback speed it was normal but I was feeling like it's in 1.5x is it you normal speed of saying?
@hardcash9930 Жыл бұрын
hi just loved the starting part where you said we are going to do a problem ans rhyming just made my day
@abhitejamandava1619 Жыл бұрын
Excellent explanation
@NM-on2zt Жыл бұрын
Crisp explanation 👏👏
@KS0607 Жыл бұрын
crystal clear ...thanks ...short and crisp...
@soumyaranjansahoo28362 жыл бұрын
mam your explanation is always best
@SumitKumar-ne9kc Жыл бұрын
thanks ,
@sujalgupta6100 Жыл бұрын
Alisha, in these tree questions, I am not able to think recursively and facing difficulty. I always get a wrong answer. What to do ?
@vijayakumareyunni6010 Жыл бұрын
Good attempt. But I could not understand what constitutes a "path." I watched many videos, except one or two, and none explained the problem and "solution" clearly.
@sssumeet2 жыл бұрын
Great Explanation. Please do provide Java Code solution if possible.
@anmolgupta6762 Жыл бұрын
I try avoiding global variables so I used an array of single element instead, you can also use global variable class Solution { public int solve(TreeNode root, int[] ans){ if(root == null) return 0; int left = solve(root.left,ans); int right = solve(root.right,ans); int st_path = Math.max(root.val,Math.max((root.val + left),(root.val + right))); int cur_path = root.val + left + right; ans[0] = Math.max(ans[0],Math.max(st_path,cur_path)); return st_path; } public int maxPathSum(TreeNode root) { int[] ans = new int[1]; ans[0] = Integer.MIN_VALUE; solve(root,ans); return ans[0]; } } This is the leetcode java code for problem : 124. Binary Tree Maximum Path Sum
@GhostRider....2 жыл бұрын
public class Solution { int Solve(TreeNode A, int ans){ if(A == null) return 0; int left = Solve(A.left, ans); int right = Solve(A.right, ans); int straight = Math.max(A.val, Math.max(left + A.val, right + A.val)); int curved = A.val + left + right; ans = Math.max(ans, Math.max(straight, curved)); return straight; } public int maxPathSum(TreeNode A) { int ans = Integer.MIN_VALUE; Solve(A, ans); return ans; } } Mam Can you tell error in this? It is giving error?
@anmolgupta6762 Жыл бұрын
Either make the ans variable global or use an array of size 1 to store ans if you want to solve like this. You cannot do like this in Java