首页
题库
面试
求职
学习
竞赛
More+
所有博客
搜索面经/职位/试题/公司
搜索
我要招人
去企业版
登录 / 注册
Ron
中国科学院大学
2016届
Java工程师
中科院应届
关注
私信
加入黑名单
举报TA
首页
刷题
圈子
项目
笔记
基本资料
真题试卷
在线编程
心理测试
回答的问题(111)
序列化二叉树
6
public class Solution { public int index = -1; String Serialize(TreeNode root) { StringBuilder s = new StringBuilder(); if(root...
发表于 2015-08-10 15:14:31
按之字形顺序打印二叉树
26
/*按层序遍历分层打印的代码,添加一段判断用以倒序输出即可*/ public ArrayList<ArrayList<Integer>> Print(TreeNode pRoot) { ArrayList<ArrayList<Integer>> ...
发表于 2015-07-23 20:00:21
把二叉树打印成多行
98
/* * 队列LinkedList完成层序遍历,用end记录每层结点数目 */ public class Solution { ArrayList<ArrayList<Integer> > Print(TreeNode pRoot) { ArrayList&...
发表于 2015-07-14 18:45:55
对称的二叉树
263
/*思路:首先根节点以及其左右子树,左子树的左子树和右子树的右子树相同 * 左子树的右子树和右子树的左子树相同即可,采用递归 * 非递归也可,采用栈或队列存取各级子树根节点 */ public class Solution { boolean isSymmetrical(TreeNode pRoo...
发表于 2015-07-13 15:12:50
二叉树的下一个结点
22
public class Solution { TreeLinkNode GetNext(TreeLinkNode pNode) { if(pNode == null){ return null; } if(pNode.right != null){ p...
发表于 2015-07-13 14:24:51
删除链表中重复的结点
3
/*注意点: * 1.pHead可能与后面值重复,也需要进行比较,故需要自定义newHead指向pHead * 2.返回的不是头结点,而是头结点指向的那个节点,即newHead.next */ public class Solution { ListNode deleteDuplication(L...
发表于 2015-07-12 14:03:22
链表中环的入口结点
1
/* * 链表环的入口,设环之前x个点,环内共m个点,当快慢第一次相遇设为是在环内入口起的的第n0个点(入口本身为环内入口起的第1个点) * 相遇时慢的不可能走超过一个环(两者在环内每次相遇的间隔为,慢的走m步会再次相遇,要么慢的在入环时和快的相遇,要么慢的走不到一个环就相遇 * 0<=...
发表于 2015-07-11 19:38:21
构建乘积数组
3
/*复杂度O(n)*/ int[] multiply(int[] A) { int length = A.length; int[] B = new int[length]; if(length <= 0) return B; int[] before ...
发表于 2015-07-11 17:27:38
数组中重复的数字
3
import java.util.HashMap; import java.util.Iterator; import java.util.Map.Entry; public class Solution { // Parameters: // numbers: an array ...
发表于 2015-07-11 15:33:49
把字符串转换成整数
2
public class Solution { public int StrToInt(String str) { if(str == "" || str == null) return 0; char[] chars = str....
发表于 2015-07-11 12:16:09
首页
上一页
4
5
6
7
8
9
10
11
下一页
末页
扫描二维码,关注牛客网
意见反馈
下载牛客APP,随时随地刷题