Given a binary tree, return the inorder traversal of its nodes’ values.
Note:
Recursive solution is trivial, could you do it iteratively?
描述
给出一棵二叉树,返回中序遍历的结果
分析
非递归,使用 Stack 来模拟递归的方式
代码
递归:
1 | /** |
非递归:
1 | public class Solution { |
Given a binary tree, return the inorder traversal of its nodes’ values.
Note:
Recursive solution is trivial, could you do it iteratively?
给出一棵二叉树,返回中序遍历的结果
非递归,使用 Stack 来模拟递归的方式
递归:
1 | /** |
非递归:
1 | public class Solution { |