2014年5月3日

摘要: 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... 阅读全文

posted @ 2014-05-03 06:34 卢泽尔 阅读(412) 评论(0) 推荐(0)

摘要: Problem Link:http://oj.leetcode.com/problems/longest-consecutive-sequence/This problem is a classical problem where we can reduce the running time by ... 阅读全文

posted @ 2014-05-03 02:40 卢泽尔 阅读(186) 评论(0) 推荐(0)

摘要: # Definition for a binary tree node# class TreeNode:# def __init__(self, x):# self.val = x# self.left = None# self.right ... 阅读全文

posted @ 2014-05-03 02:18 卢泽尔 阅读(279) 评论(0) 推荐(0)

2014年4月22日

摘要: Problem Link:http://oj.leetcode.com/problems/surrounded-regions/We can do follows in the 2D board.Use BFS from all 'O' cells on the boundary and mark ... 阅读全文

posted @ 2014-04-22 09:48 卢泽尔 阅读(106) 评论(0) 推荐(0)

摘要: Problem Link:http://oj.leetcode.com/problems/palindrome-partitioning-ii/We solve this problem by using Dynamic Programming.Optimal Sub-structureAssume... 阅读全文

posted @ 2014-04-22 09:25 卢泽尔 阅读(147) 评论(0) 推荐(0)

2014年4月21日

摘要: Problem Link:http://oj.leetcode.com/problems/palindrome-partitioning/We solve this problem using Dynamic Programming. The problem holds the property o... 阅读全文

posted @ 2014-04-21 11:28 卢泽尔 阅读(198) 评论(0) 推荐(0)

摘要: Problem Link:http://oj.leetcode.com/problems/valid-palindrome/The following two conditions would simplify the problem:only alphanumerci characters con... 阅读全文

posted @ 2014-04-21 02:56 卢泽尔 阅读(159) 评论(0) 推荐(0)

2014年4月8日

摘要: Problem link:http://oj.leetcode.com/problems/gas-station/We can solve this problem by following algorithm. CompleteCircuit(gas, cost): let n be the number of stations // Check if there exists i such that A[i,n] >= 0 if (sum of gas) > (sum of cost) return -1 // There is no valid i such that A[. 阅读全文

posted @ 2014-04-08 08:27 卢泽尔 阅读(428) 评论(0) 推荐(0)

2014年4月7日

摘要: Problem link:http://oj.leetcode.com/problems/single-number-ii/The problem seems like the Single Number. Suppose we have following (3m+1) numbers in the array A:x0, x1, x1, x1, ..., xm, xm, xmWe are asked to find out the value of x0.However we cannot solve it using XOR since all xi has odd number of 阅读全文

posted @ 2014-04-07 04:54 卢泽尔 阅读(178) 评论(0) 推荐(0)

摘要: Prolbem link:http://oj.leetcode.com/problems/single-number/This prolbem can be solved by using XOR(exclusive OR) operation. Let x, y, and z be any numbers, and XOR has following properties:x XOR 0 is itself, i.e. x XOR 0 = 0;x XOR x is 0, i.e. x XOR x = 0;XOR is associative, i.e. (x XOR y) XOR z = x 阅读全文

posted @ 2014-04-07 02:12 卢泽尔 阅读(194) 评论(0) 推荐(0)