recursive
-
[LeetCode] Binary Tree Inorder Traversal알고리즘 2019. 11. 26. 17:37
문제 Given a binary tree, return the inorder traversal of its nodes' values. Example: Input: [1,null,2,3] 1 \ 2 / 3 Output: [1,3,2] Follow up: Recursive solution is trivial, could you do it iteratively? Apporach Inorder traversal: 왼쪽 자식-> 자신 -> 오른쪽 자식 순으로 트리 탐색 Recursive로 풀면 직관적이고 함수 스택 말고 실제 stack을 활용해 반복문으로 풀 수도 있다. Code Recursive: https://github.com/chi3236/algorithm/blob/master/LeetCode_Binary..