바위타는 두루미
[leetcode]94. Binary Tree Inorder Traversal 본문
728x90
94. Binary Tree Inorder Traversal
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]
class Solution(object):
def inorderTraversal(self, root):
"""
:type root: TreeNode
:rtype: List[int]
"""
if not root:
return []
else:
return self.inorderTraversal(root.left) + [root.val] + self.inorderTraversal(root.right)
'Study > Algorithm' 카테고리의 다른 글
[leetcode]105. Construct Binary Tree from Preorder and Inorder Traversal (0) | 2019.08.09 |
---|---|
[leetcode]103. Binary Tree Zigzag Level Order Traversal (0) | 2019.08.09 |
[leetcode]160. Intersection of Two Linked Lists (1) | 2019.08.08 |
[leetcode] 2. add two numbers (0) | 2019.08.07 |
[프로그래머스]도둑질 (3) | 2019.08.01 |
Comments