[Java] Leetcode 144. Binary Tree Preorder Traversal (Iteratively & Recursively) [Binary Tree #1]

preview_player
Показать описание
In this video, I'm going to show you how to solve Leetcode 144. Binary Tree Preorder Traversal (Iteratively & Recursively) which is related to Binary Tree.

Here’s a quick rundown of what you’re about to learn:

⭐️ Course Contents ⭐️
⌨️ (0:00) Recursive Solution
⌨️ (3:50) Iterative Solution

In the end, you’ll have a really good understanding on how to solve Leetcode 144. Binary Tree Preorder Traversal (Iteratively & Recursively) and questions that are similar to this Binary Tree.

Рекомендации по теме
Комментарии
Автор

I like how you are checking the left and right nodes for null before adding. I have seen solutions where they are added regardless and as a result the top node needs to be checked for null before adding to the pre order list. It's easier to read and prevents the stack from growing larger than required.

MangoTroll
Автор

Thank you so much!!! I stuck in putting right in stack first for a long time, and you help me a lot!!

bishengzeng
Автор

Excellent Presentation!!! By the way what is the name of the tool kit that you use to draw the diagrams???

rcruz
Автор

I know this is silly doubt😅 but why did u use private instead of public ?

madetolaugh
join shbcf.ru