1 | 给定一个二叉树,返回它的中序 遍历。 |
递归方法
1 | private class TreeNode { |
非递归方法,使用栈,先把左子树上的每个节点加入
出栈时遍历,如果有右子树,再把右子树加入栈中,如果右子树有左子树,继续添加左子树,
直至遍历完成。
1 | public List<Integer> inorderTraversal(TreeNode root) { |
评论区大佬的简洁写法
1 |
|
1 | 给定一个二叉树,返回它的中序 遍历。 |
递归方法
1 | private class TreeNode { |
非递归方法,使用栈,先把左子树上的每个节点加入
出栈时遍历,如果有右子树,再把右子树加入栈中,如果右子树有左子树,继续添加左子树,
直至遍历完成。
1 | public List<Integer> inorderTraversal(TreeNode root) { |
评论区大佬的简洁写法
1 |
|
tag:
缺失模块。
1、请确保node版本大于6.2
2、在博客根目录(注意不是yilia根目录)执行以下命令:
npm i hexo-generator-json-content --save
3、在根目录_config.yml里添加配置:
jsonContent:
meta: false
pages: false
posts:
title: true
date: true
path: true
text: false
raw: false
content: false
slug: false
updated: false
comments: false
link: false
permalink: false
excerpt: false
categories: false
tags: true