2014年4月3日

摘要: Problem Link:http://oj.leetcode.com/problems/binary-tree-postorder-traversal/The post-order-traversal of a binary tree is a classic problem, the recursive way to solve it is really straightforward, the pseudo-code is as follows. RECURSIVE-POST-ORDER-TRAVERSAL(TreeNode node) if node is NULL retur... 阅读全文

posted @ 2014-04-03 23:36 卢泽尔 阅读(443) 评论(0) 推荐(0)

摘要: Problem Link:http://oj.leetcode.com/problems/lru-cache/Long long ago, I had a post for implementing the LRU Cache in C++ in my homepage:http://www.cs.uml.edu/~jlu1/doc/codes/lruCache.htmlSo this time, I am trying to use Python to implement a LRU Cache.However, the result is Time Limit Exceeded.....M 阅读全文

posted @ 2014-04-03 22:56 卢泽尔 阅读(263) 评论(0) 推荐(0)

摘要: Problem Link:http://oj.leetcode.com/problems/interleaving-string/Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.For example,Given:s1 = "aabcc",s2 = "dbbca",When s3 = "aadbbcbcac", return true.When s3 = "aadbbbaccc", return false.T 阅读全文

posted @ 2014-04-03 05:01 卢泽尔 阅读(384) 评论(0) 推荐(0)

2014年3月13日

摘要: Problem:Sort a linked list using insertion sort.The node of the linked list is defined as:/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */The insertion sorting is one of the simpleset sorting algor... 阅读全文

posted @ 2014-03-13 03:05 卢泽尔 阅读(264) 评论(0) 推荐(0)

摘要: Problem link:http://oj.leetcode.com/problems/reverse-words-in-a-string/Given an input string, reverse the string word by word. For example,Given s = "... 阅读全文

posted @ 2014-03-13 02:52 卢泽尔 阅读(286) 评论(2) 推荐(0)

2014年1月10日

摘要: Problem:Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.Suppose that the structure Point is already defined in as following:/** * Definition for a point. * struct Point { * int x; * int y; * Point() : x(0), y(0) {} * Point(int a, int... 阅读全文

posted @ 2014-01-10 10:53 卢泽尔 阅读(2351) 评论(1) 推荐(0)

2014年1月9日

摘要: 倒霉的LeetCode Online Judge只支持C++和Java……用了多年的python,C++都快忘光了,LeetCode OJ系列就当C++复习回顾吧……Problem DescriptionEvaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -, *, /. Each operand may be an integer or another expression. Some examples: ["2", "1 阅读全文

posted @ 2014-01-09 11:10 卢泽尔 阅读(382) 评论(0) 推荐(0)

摘要: 今天刚刚申请了博客园的博客,也是心血来潮,突然又想再弄一个blog了。之前在sina的blog是和前女友共同维护的,后来出国了、分手了、伤心了,就再也没去过。之后,便在xiaonei上写一些随笔,开始写【奔三那些年】,在2013年发生了一些事情:遇到了现在的妻子结婚了30了……终于,不用再奔三了……结婚后我也很少上xiaonei、微博、QQ、各大网站了。前几天,突然很怀念坐在电脑前噼里啪啦砸键盘的感觉,当然不是指写程序。于是做了几天的research,还是决定在cnblogs安一个新家——克己猪屋,一个既严肃又俏皮的名字 :D希望一切重新开始,做一个成功的卢泽尔~~~写在2014年元月9日。 阅读全文

posted @ 2014-01-09 09:23 卢泽尔 阅读(158) 评论(0) 推荐(0)