Max Sum Path in Binary Tree

  Рет қаралды 6,262

Code with Alisha

Code with Alisha

Күн бұрын

Пікірлер: 21
@smanivesh
@smanivesh 2 жыл бұрын
This is the BEST explanation for this question on you tube.❤
@fine2981
@fine2981 Жыл бұрын
Wow thank you so much ....best explanation available on you tube for this question.
@saishanmukh3805
@saishanmukh3805 2 ай бұрын
This is such a neat explanation!
@antojoshwa966
@antojoshwa966 3 жыл бұрын
Great explanation . Deserve more subs
@mohakbansal5866
@mohakbansal5866 2 жыл бұрын
best solution keep making more videos
@TarunKumar-cn6in
@TarunKumar-cn6in 2 жыл бұрын
Best explanation 👍
@neerajmahapatra5239
@neerajmahapatra5239 2 жыл бұрын
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
@hardcash9930 Жыл бұрын
hi just loved the starting part where you said we are going to do a problem ans rhyming just made my day
@abhitejamandava1619
@abhitejamandava1619 Жыл бұрын
Excellent explanation
@NM-on2zt
@NM-on2zt Жыл бұрын
Crisp explanation 👏👏
@KS0607
@KS0607 Жыл бұрын
crystal clear ...thanks ...short and crisp...
@soumyaranjansahoo2836
@soumyaranjansahoo2836 2 жыл бұрын
mam your explanation is always best
@SumitKumar-ne9kc
@SumitKumar-ne9kc Жыл бұрын
thanks ,
@sujalgupta6100
@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
@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.
@sssumeet
@sssumeet 2 жыл бұрын
Great Explanation. Please do provide Java Code solution if possible.
@anmolgupta6762
@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....
@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
@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
@bharathkumar5870
@bharathkumar5870 3 жыл бұрын
You solved this problem in your previous videos
@lalalajpat8602
@lalalajpat8602 Жыл бұрын
Gr*
Maximum path sum from any node
14:24
Code with Alisha
Рет қаралды 3,5 М.
Leetcode 2401. Longest Nice Subarray | Weekly Contest 2401.
19:54
Code with Alisha
Рет қаралды 6 М.
Don't underestimate anyone
00:47
奇軒Tricking
Рет қаралды 25 МЛН
Long Nails 💅🏻 #shorts
00:50
Mr DegrEE
Рет қаралды 18 МЛН
How to Fight a Gross Man 😡
00:19
Alan Chikin Chow
Рет қаралды 19 МЛН
When Cucumbers Meet PVC Pipe The Results Are Wild! 🤭
00:44
Crafty Buddy
Рет қаралды 61 МЛН
Leetcode 894. All Possible Full Binary Trees
29:08
Code with Alisha
Рет қаралды 4,3 М.
2 Years of C++ Programming
8:20
Zyger
Рет қаралды 3,9 М.
How to Build your marketing Business #entrepreneurship #podcast
26:47
Code with Alisha
Рет қаралды 1,1 М.
Only Geniuses Can Solve This | A Challenging Exponential Equation
10:46
Building a Women's Health Business : Sanjana, Founder of ThePinkBox
29:49
Don't underestimate anyone
00:47
奇軒Tricking
Рет қаралды 25 МЛН