首页
题库
面试
求职
学习
竞赛
More+
所有博客
搜索面经/职位/试题/公司
搜索
我要招人
去企业版
登录 / 注册
JacobGo!
阿里巴巴_云智能_Java开发
门头沟学院
2019届
Java工程师
关注
私信
加入黑名单
举报TA
首页
刷题
圈子
项目
笔记
基本资料
真题试卷
在线编程
心理测试
回答的问题(181)
二叉树的后序遍历
1
import java.util.*; public class Solution { public ArrayList<Integer> postorderTraversal(TreeNode root) { ArrayList<Integer> r...
发表于 2017-08-10 10:31:19
求二叉树的前序遍历
1
package go.jacob.day0527.stackqueue; import java.util.ArrayList; import java.util.List; import java.util.Stack; /** * 给定一个二叉树,返回它的 前序 遍历。 * <p...
发表于 2017-08-10 10:14:36
二叉树根节点到叶子节点的所有路径和
1
public int sumNumbers(TreeNode root) { if (root == null) return 0; int sum = 0; return sumNumbers(root, sum); } private int sumNumbers(Tre...
发表于 2017-08-10 09:57:57
二叉树中的最大路径和
20
/* * 124. Binary Tree Maximum Path Sum * 解题思路:(转载自:http://blog.csdn.net/linhuanmars/article/details/22969069) * 这道题是求树的路径和的题目,不过和平常不同的是这里的路径不仅可以从根到...
发表于 2017-08-09 11:19:42
填充每个节点指向最右节点的next指针 ii
9
public void connect(TreeLinkNode root) { while (root != null) { //tmpLevelFirst为新建立的每层第一个节点(为了方便后面遍历当前行节点) TreeLinkNode tmpLevelFirst = new Tr...
发表于 2017-08-09 10:35:14
填充每个节点指向最右节点的next指针
1
/* * 推荐解答 */ public void connect(TreeLinkNode root) { TreeLinkNode level_start = root; while (level_start != null) { TreeLinkNode cur = le...
发表于 2017-08-09 10:04:27
二叉树中和为某一值的路径(一)
3
* 递归求解 */ public boolean hasPathSum(TreeNode root, int sum) { if (root == null) return false; if (sum == root.val && root.left == nu...
发表于 2017-08-08 10:09:17
二叉树的最小深度
1
public class Solution { public int run(TreeNode root) { if(root==null) return 0; if(root.left==null) return 1+run(root.right); if(root...
发表于 2017-08-07 11:30:16
判断二叉树是否为平衡二叉树
11
public boolean isBalanced(TreeNode root) { if (root == null) return true; return getHeight(root) != -1; } /* * 高度差如果大于1,返回-1 */ privat...
发表于 2017-08-07 11:15:19
将升序数组转化为平衡二叉搜索树
7
package go.jacob.day807; /** * 108. Convert Sorted Array to Binary Search Tree * @author Jacob * 这道题是二分查找树的题目,要把一个有序数组转换成一颗二分查找树。 * 从本质来看,如果把一个数组...
发表于 2017-08-07 10:53:19
首页
上一页
4
5
6
7
8
9
10
11
下一页
末页
扫描二维码,关注牛客网
意见反馈
下载牛客APP,随时随地刷题