filmov
tv
LeetCode 144. Binary Tree Preorder Traversal - Iterative & Recursive solutions explained

Показать описание
Binary Tree Preorder Traversal iterative version using stack is a frequently asked question in coding interviews. DFS is the core of the logic again here .If you haven't yet seen the 3 simple steps to master dfs you must watch that. I have used those steps here while solving this problem too. In this session, I wrote two versions of the solution also please do the homework for a more optimized solution. #tree #leetcode #preorder
0:00 Preorder traversal DFS
2:45 Iterative approach with Stack
0:00 Preorder traversal DFS
2:45 Iterative approach with Stack