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...
分类:
其他好文 时间:
2014-05-05 23:01:41
阅读次数:
374
# Definition for a binary tree node# class
TreeNode:# def __init__(self, x):# self.val = x# self.left = None# self.right
...
分类:
其他好文 时间:
2014-05-05 22:56:23
阅读次数:
419
Problem
Link:http://oj.leetcode.com/problems/longest-consecutive-sequence/This problem
is a classical problem where we can reduce the running time by ...
分类:
其他好文 时间:
2014-05-05 22:55:22
阅读次数:
552
遇到的问题:input{1,1,1}, output{1,1}, expected{1},
原因在于若temp.val==temp.next.val, 则需要temp.next=temp.next.next,
这时候就不要temp=temp.next了注意停止条件不光是temp!=null,还应该有...
分类:
其他好文 时间:
2014-05-05 22:47:08
阅读次数:
454
Link:http://oj.leetcode.com/problems/reverse-nodes-in-k-group/Given a linked
list, reverse the nodes of a linked listkat a time and return its modifie...
分类:
其他好文 时间:
2014-05-05 22:46:42
阅读次数:
456
Link:http://oj.leetcode.com/problems/reverse-linked-list-ii/Reverse a linked
list from positionmton. Do it in-place and in one-pass.For example:Given1...
分类:
其他好文 时间:
2014-05-05 22:46:11
阅读次数:
411
Link:http://oj.leetcode.com/problems/swap-nodes-in-pairs/Given a linked list,
swap every two adjacent nodes and return its head.For example,Given1->2-...
分类:
其他好文 时间:
2014-05-05 22:45:37
阅读次数:
331
很锻炼DP/recursive思路的一道题,个人感觉DP/recursive算是比较难写的题目了。这道题解法的巧妙之处在于巧用-1,并且使用临时存储,节省了很多开支。这道题同时也在Career
Cup上面出现过这道题我两次调试通过,第一次错是因为input{}, output false, expe...
分类:
其他好文 时间:
2014-05-05 22:45:10
阅读次数:
352
Problem
Link:http://oj.leetcode.com/problems/word-ladder/Two typical techniques are
inspected in this problem:Hash Table. One hash set is the words di...
分类:
其他好文 时间:
2014-05-05 22:44:44
阅读次数:
393
1 /** 2 * Definition for binary tree 3 * public
class TreeNode { 4 * int val; 5 * TreeNode left; 6 * TreeNode right; 7 *
TreeNo...
分类:
其他好文 时间:
2014-05-05 22:43:14
阅读次数:
313