摘要: 1、LCS 2、CSD: 1、s1.length==0,return s2.length; 2、s2.length==0,return s1.length; 3、if s1.charat(i)==s2.charat(j),res[i][j]=res[i-1][j-1] else res[i][j]= 阅读全文
posted @ 2016-08-07 17:55 pku_smile 阅读(208) 评论(0) 推荐(0) 编辑
摘要: One way to serialize a binary tree is to use pre-order traversal. When we encounter a non-null node, we record the node's value. If it is a null node, 阅读全文
posted @ 2016-02-02 11:02 pku_smile 阅读(131) 评论(0) 推荐(0) 编辑
摘要: Odd Even Linked ListGiven a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the nod... 阅读全文
posted @ 2016-01-16 15:06 pku_smile 阅读(583) 评论(0) 推荐(0) 编辑
摘要: http://www.ruanyifeng.com/blog/2013/05/Knuth%E2%80%93Morris%E2%80%93Pratt_algorithm.html 阅读全文
posted @ 2015-08-05 15:38 pku_smile 阅读(134) 评论(0) 推荐(0) 编辑
摘要: 标题:Bitwise AND of Numbers Range通过率:25.7%难度:中等Given a range [m, n] where 0 >=1 9 n>>=110 offset+=111 return m<<offset 阅读全文
posted @ 2015-04-23 16:53 pku_smile 阅读(191) 评论(0) 推荐(0) 编辑
摘要: 标题:Remove Linked List Elements通过率:30.5%难度:简单Remove all elements from a linked list of integers that have valueval.ExampleGiven:1 --> 2 --> 6 --> 3 -->... 阅读全文
posted @ 2015-04-23 15:53 pku_smile 阅读(119) 评论(0) 推荐(0) 编辑
摘要: 标题:Happy Number通过率:34.3%难度:简单Write an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Start... 阅读全文
posted @ 2015-04-23 15:33 pku_smile 阅读(106) 评论(0) 推荐(0) 编辑
摘要: 标题:Rotate List通过率:21.8%难度:中等Given a list, rotate the list to the right bykplaces, wherekis non-negative.For example:Given1->2->3->4->5->NULLandk=2,ret... 阅读全文
posted @ 2015-04-17 10:55 pku_smile 阅读(176) 评论(0) 推荐(0) 编辑
摘要: 标题:Gas Station通过率:25.7%难度:中等There areNgas stations along a circular route, where the amount of gas at stationiisgas[i].You have a car with an unlimite... 阅读全文
posted @ 2015-04-15 21:23 pku_smile 阅读(165) 评论(0) 推荐(0) 编辑
摘要: 标题:Reverse Linked List II通过率:26.2%难度:中等Reverse a linked list from positionmton. Do it in-place and in one-pass.For example:Given1->2->3->4->5->NULL,m=... 阅读全文
posted @ 2015-04-13 10:29 pku_smile 阅读(184) 评论(0) 推荐(0) 编辑