Daily LeetCode 94. Binary Tree Inorder Traversal
https://leetcode.com/problems/binary-tree-inorder-traversal/
Medium
问题描述:
Given a binary tree, return the inorder traversal of its nodes’ values.
Example:
1 | Input: [1,null,2,3] |
Follow up: Recursive solution is trivial, could you do it iteratively?
思路及代码:
这一题是要中序遍历二叉树
方法1:
采用递归的方式进行遍历
1 | def inorderTraversal(root): |
方法2:
采用非递归的方式进行中序遍历
1 | class Solution: |