Given a binary tree, return the preorder traversal of its nodes’ values.
1 | For example : |
题意:
二叉树的先根序遍历。
思路:
方法一:
二叉树的先根序遍历递归实现。
1 | struct TreeNode { |
方法二:
二叉树的先根序遍历非递归实现,借助栈。
1 | class Solution |
Given a binary tree, return the preorder traversal of its nodes’ values.
1 | For example : |
二叉树的先根序遍历。
二叉树的先根序遍历递归实现。
1 | struct TreeNode { |
二叉树的先根序遍历非递归实现,借助栈。
1 | class Solution |