1
来源:互联网 发布:python 爬虫工作原理 编辑:程序博客网 时间:2024/06/05 05:26
public class Solution { public ArrayList<Integer> inorderTraversal(TreeNode root) {ArrayList<Integer> result = new ArrayList<Integer>();Stack<TreeNode> st = new Stack<TreeNode>();while (root != null || !st.isEmpty()) {if (root == null) {// Already in most left, visit left's parent, point to parent's right (subtree)root = st.pop();result.add(root.val);//System.out.print(root.val);//st.push(root.right);root = root.right;} else {// Not in most left, push parent, go to most left (subtree)st.push(root);root = root.left;}}return result;}}
0 0
- 1
- 1
- 1
- 1
- 1
- 1
- 1》
- 1
- 1
- 1
- 1
- (1)
- 1
- 1
- 1
- 1
- 1
- 1
- cocoStudio UI编辑器 学习总结(转)
- 一个资深程序员看12306
- 小伙伴们,你们知道草根站长论坛的创业神器是什么吗?
- /root/.bashrc与/etc/profile的异同
- 修改Flume Log4j Appender
- 1
- Hadoop常见的45个问题
- Maven仓库汇总
- Spring@Autowired注解与自动装配
- [Linux]ln -s对目录建立符号连接后报错“符号连接层数过多”的解决办法
- leetcode Minimum Depth of Binary Tree 1.11 难度系数1
- 插入排序算法
- 英特尔大败局
- 三大措施设置数据库安全 保障网站安全运营