Binary Tree Max Path Sum (LeetCode Day 29)
Вставка
- Опубліковано 12 лис 2024
- Given a binary tree with values in nodes, find a path with the maximum sum of values. This coding interview problem is quite similar to other tree problems like "find height" or subtrees or any kind of dp on trees - it's just about thinking what should be returned by DFS.
Leetcode April Challenge - leetcode.com/e...
Subscribe for more educational videos on algorithms, coding interviews and competitive programming.
Github repository: github.com/Err...
Live streams on 2nd YT channel and on Twitch: / errichto2 & / errichto
FB and Twitter: / errichto & / errichto
Frequently Asked Questions: github.com/Err...
#Coding #Programming
This problem is something similar to leetcode day 11 problem about tree's diameter, wich was quite hard for me, but after your explanations I was able to solve this by my own, so thx for you work Errichto! :)
Hah, you are right. I didn't even remember that there was Diameter problem 2-3 weeks ago :D
With due respect I just say your programs are very clear in concept and simple to implement. It naturally feels that it's so simple to understand the logic and implement it. Thanks for do it so effortlessly.
Thank you this was clear and concise. We love your drawings.
thanks :)
What so great explanation, including the wrong answer, you are a grand master!
Thanks for explaining so well.
The last part was similar to Kadane's algo.
successfully completed 30 day leetcode challenge !!! thank you
Your videos have high ratio of likes to dislikes . Please continue making these kind of problem solving regularly. Thanks.
This was an amazingly simple explanation for this, thank you!
Literally the best programmer on UA-cam.
I was signed out while watching this.
Signed in again just to like it. :)
Thankyou Errichto! /\
I found this difficult tbh and your solution was extremely elegant.
Will you be doing the May challenge as well?
I believe he mentioned in the last video that one LeetCode challenge is enough for him. Correct me if I'm wrong, but what a sad information that we would miss this content.
how does dfs return value matter as it is not updated .The value main function is returning is answer not return value of dfs
Beautifully explained!
Great content! I hope you do participate in the harder May questions
Thank you once again for the awesome explanation.
Hi errichto, I can't tackle graph colouring problem from Atcoder ABC. Give some advice to how I tackle problems related to graphs.
Loved the explanation
how to produce the input like in the code from left to right for the tree? If I need to add inputs for tree from the command line? Thanks
Hi Errichto, where are we using variable answer from line 21 ?
Thank you very much for yours videos they are super helpful. I've a question to your implementation. Will it work if in the tree will be only negative values? Thank you in advance!
yes answer will be a 0 then
simple!!!!!!
Thanks a ton!!!! i was struggling with this
Can you do a tutorial for Hash Tables and Maps? That is another harder concept to grasp. Love your tutorials. Thank you.
hy Erritcho wich should i learn after c++: java or python? Thanks for answering!
google -> which programming language should I learn?
(if you do it only for competitive programming, it should be c++)
@@Errichto thanks for answering! Subscriber from Romania
Since I've just watched your DP tutorials and this, is the approach straightforward for these problems?
Find number of paths in the tree where their path sum (by nodes' value) is:
- at most K
- equal K
- at least K.
Another problem is:
Find maximal path sum by nodes' value in the tree where the number of nodes is at most K / equal K / at least K.
It's quite hard to do these better than O(N^2). I think that it's possible only if path length means the number of nodes, not the sum of values. Then it is bottom-up dp on a tree with "smaller to greater" principle.
beautiful perfect explaination sir. Thank you.
Which whiteboarding / free-drawing software does Errichto use for this presentations?
Love it bro!
You r the our legend 😊
one word Fan of You
if you dont need to consider that negative path then why didnt we take max(x,y,0)+root->val ....Because there x=-1 y=0 so for its parent if we are returning a max path with node 2,then return max(x,y,0)+root->val will be 0+2 i.e 2.
Could you explain this plz
Awesome content! What program do you use for drawing ?
Great great great!
what if the root is itself negative?
Could you cover Backtracking?
This problem was always there on leetcode , I don't understand what's new
3 adblockers 😂
I don't even remember why I need more than 1...
Did he just read, solved that question and explained it in under 9 minutes
Next stream when?
within a week, I think
watch out for schedule update at www.twitch.tv/errichto
@@Errichto oh nice. This is great. I am waiting for your next stream. I love your stream so so much. Which day you stream please tell me at first please.
You are awesome Awesome Awesome
Nice
Is it okay to start competitive programming with python
I guess yes
NO!
No not at all
yes, and your question was already asked so many times
Ladies and gentlemen this is .. 😊😊
What the teddy is looking at? Is he sad?
Please make some tutorial video about Graph theory:)
I'm going to do that ;)
@@Errichto thanks in advance:)
How is this a LC hard but also minimum height trees is a LC medium -_-
Hi errichto, how can I become that good at programming like you and how I can get all that knowledge that you have in c++ about language and problem solving, I'm new in this world. I will thankful if you help me, with books names and stuff like that...
PD: I don't speak english, then I apologize for my writting.
for c++, find any tutorial or course online
for algorithms, just do problems and read this github.com/Errichto/youtube/wiki/How-to-practice%3F
@@Errichto Thank you so much!!
As I had already commented below but no one wants to be a mentor.
Could I find someone who is willing to solve daily 4-5 problems with me please 🙇♀️
why no hand raised bye :(
*Errichto please conduct some contest on hackerrank for your subscribers please at least monthly once*
Does Hackerrank conduct contests at least monthly? :D
@@Errichto No they won't so I do want you to conduct it.
@@Vijay-ph4gb Creating a contest requires a huge amount of effort and time.
@@Errichto please do it for the subscribers.... Like me.
hackerrank is stupid
where is your silver tick from the youtube?
Still coming, I guess
Please participate in May challenge.
When will increase font??????? This is my 3re effin comment.