Skip to content

Commit

Permalink
二叉树中序遍历
Browse files Browse the repository at this point in the history
  • Loading branch information
rinwf committed Nov 4, 2018
1 parent 251a1f1 commit 2e309ca
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lc94. Binary Tree Inorder Traversal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None


class Solution:
def inorderTraversal(self, root):
"""
:type root: TreeNode
:rtype: List[int]
"""
def dfs(root):
if not root:
return
dfs(root.left)
res.append(root.val)
dfs(root.right)
res = []
dfs(root)
return res

0 comments on commit 2e309ca

Please sign in to comment.