上一页 1 ··· 9 10 11 12 13 14 15 下一页
摘要: Clone an undirected graph. Each node in the graph contains alabeland a list of itsneighbors.OJ's undirected graph serialization:Nodes are labeled uniq... 阅读全文
posted @ 2014-09-15 20:41 birdhack 阅读(177) 评论(0) 推荐(0) 编辑
摘要: Sort a linked list using insertion sort.题目意思是用插入排序对单链表进行排序,做法是返回一个新的单链表,每次插入的时候都添加一个新建的节点。/** * Definition for singly-linked list. * public class List... 阅读全文
posted @ 2014-09-13 15:05 birdhack 阅读(120) 评论(0) 推荐(0) 编辑
摘要: Sort a linked list inO(nlogn) time using constant space complexity.归并排序的基本思想是:找到链表的middle节点,然后递归对前半部分和后半部分分别进行归并排序,最后对两个以排好序的链表进行Merge。/** * Definitio... 阅读全文
posted @ 2014-09-13 12:07 birdhack 阅读(93) 评论(0) 推荐(0) 编辑
摘要: Reverse digits of an integer.Example1:x = 123, return 321Example2:x = -123, return -321 1 public class Solution { 2 public int reverse(int x) { 3 ... 阅读全文
posted @ 2014-09-11 19:06 birdhack 阅读(125) 评论(0) 推荐(0) 编辑
摘要: Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given[100, 4, 200, 1, 3, 2],The longest ... 阅读全文
posted @ 2014-09-11 18:46 birdhack 阅读(101) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree containing digits from0-9only, each root-to-leaf path could represent a number.An example is the root-to-leaf path1->2->3which rep... 阅读全文
posted @ 2014-09-10 21:28 birdhack 阅读(111) 评论(0) 推荐(0) 编辑
摘要: There areNgas stations along a circular route, where the amount of gas at stationiisgas[i].You have a car with an unlimited gas tank and it costscost[... 阅读全文
posted @ 2014-09-04 18:17 birdhack 阅读(101) 评论(0) 推荐(0) 编辑
摘要: There areNchildren standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requi... 阅读全文
posted @ 2014-09-03 20:52 birdhack 阅读(134) 评论(0) 推荐(0) 编辑
摘要: Given an array of integers, every element appearsthreetimes except for one. Find that single one.Note:Your algorithm should have a linear runtime comp... 阅读全文
posted @ 2014-09-03 19:36 birdhack 阅读(87) 评论(0) 推荐(0) 编辑
摘要: Given an array of integers, every element appearstwiceexcept for one. Find that single one.Note:Your algorithm should have a linear runtime complexity... 阅读全文
posted @ 2014-09-03 11:22 birdhack 阅读(97) 评论(0) 推荐(0) 编辑
上一页 1 ··· 9 10 11 12 13 14 15 下一页