首页
题库
面试
求职
学习
竞赛
More+
所有博客
搜索面经/职位/试题/公司
搜索
我要招人
去企业版
登录 / 注册
Ron
中国科学院大学
2016届
Java工程师
中科院应届
关注
私信
加入黑名单
举报TA
首页
刷题
圈子
项目
笔记
基本资料
真题试卷
在线编程
心理测试
回答的问题(111)
二叉树根节点到叶子节点的所有路径和
0
public int sum = 0; public int sumNumbers(TreeNode root) { if(root == null){ return 0; } sumNum(root, root.val+""); return sum; ...
发表于 2016-07-15 12:33:48
最长的连续元素序列长度
27
public int longestConsecutive(int[] num) { Set<Integer> set = new HashSet<Integer>(); for(int n : num){ set.add(n...
发表于 2016-07-09 10:59:21
包围区域
35
/* * 所有与四条边相连的O都保留,其他O都变为X * 遍历四条边上的O,并深度遍历与其相连的O,将这些O都转为* * 将剩余的O变为X * 将剩余的*变为O */ public int rowNum = 0; public int colNum = 0; publ...
发表于 2016-07-09 10:14:10
复制无向图
0
//广度优先遍历 public UndirectedGraphNode cloneGraph(UndirectedGraphNode node) { if(node == null){ return null; } Map<Integer, UndirectedGr...
发表于 2016-07-07 15:52:17
加油站
1
/* * 用最后一个点作为起点,当油量够时则end++,当油量不够就start后退一个直至到0,换起点后不需计算后续点,只需要计算刚才结余即可 */ public int canCompleteCircuit(int[] gas, int[] cost) { if(g...
发表于 2016-07-06 14:58:51
拷贝有随机指针的链表
10
/* * 每个节点后都插入一个前面节点的拷贝,全部插入后再遍历,改变拷贝的next与random,形成新链表 * cur, nex * for node = head : tail : 2 * cur = node * copy = copyOf(cur) *...
发表于 2016-07-05 12:55:35
链表中环的入口节点
1
/*快慢指针第一次相遇的点定为N1,两个慢指针分别从起点和N1开始运动, 再次相遇的点就是环入口,在找N1的过程中出现NULL则说明没有环*/ public ListNode detectCycle(ListNode head) { if(head == null || head....
发表于 2016-07-03 15:03:32
链表的插入排序
0
public ListNode insertionSortList(ListNode head) { if(head == null || head.next == null){ return head; } ListNode h = new ListNode(-1); Lis...
发表于 2016-07-02 22:04:02
链表排序
0
//堆排序 public ListNode sortList(ListNode head) { if(head == null || head.next == null){ return head; } ArrayList<Integer> list =...
发表于 2016-07-02 16:52:06
二叉树的最小深度
0
public int run(TreeNode root) { if(root == null){ return 0; } int depth = Integer.MAX_VALUE; if(root.left == null &&...
发表于 2016-06-29 15:05:51
首页
上一页
1
2
3
4
5
6
7
8
下一页
末页
扫描二维码,关注牛客网
意见反馈
下载牛客APP,随时随地刷题