2015年4月22日

202. Happy Number

摘要: Write an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any positive integer... 阅读全文

posted @ 2015-04-22 11:39 shini 阅读(119) 评论(0) 推荐(0) 编辑

2015年4月18日

141. Linked List Cycle

摘要: Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?Cracking Interview书上原题,快慢指针,如果有环肯定相遇。/** *... 阅读全文

posted @ 2015-04-18 08:14 shini 阅读(106) 评论(0) 推荐(0) 编辑

142. Linked List Cycle II

摘要: Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull.Follow up:Can you solve it without using extra space?Cra... 阅读全文

posted @ 2015-04-18 08:11 shini 阅读(102) 评论(0) 推荐(0) 编辑

143. Reorder List

摘要: Given a singly linked listL:L0→L1→…→Ln-1→Ln,reorder it to:L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.For exam... 阅读全文

posted @ 2015-04-18 08:06 shini 阅读(80) 评论(0) 推荐(0) 编辑

94. Binary Tree Inorder Traversal

摘要: Given a binary tree, return theinordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,3,2].Note... 阅读全文

posted @ 2015-04-18 07:18 shini 阅读(84) 评论(0) 推荐(0) 编辑

144. Binary Tree Preorder Traversal

摘要: Given a binary tree, return thepreordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,2,3].先pu... 阅读全文

posted @ 2015-04-18 06:55 shini 阅读(88) 评论(0) 推荐(0) 编辑

145. Binary Tree Postorder Traversal

摘要: Given a binary tree, return thepostordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[3,2,1].No... 阅读全文

posted @ 2015-04-18 06:39 shini 阅读(131) 评论(0) 推荐(0) 编辑

2015年4月17日

201. Bitwise AND of Numbers Range

摘要: Given a range [m, n] where 0 > 1; while (s != 0) { a |= s; s >>= 1; } return m&n&~a... 阅读全文

posted @ 2015-04-17 01:00 shini 阅读(130) 评论(0) 推荐(0) 编辑

2015年4月16日

146. LRU Cache

摘要: Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations:getandset.get(key)- Get the valu... 阅读全文

posted @ 2015-04-16 05:22 shini 阅读(153) 评论(0) 推荐(0) 编辑

148. Sort List

摘要: Sort a linked list inO(nlogn) time using constant space complexity.Merge Sort./** * Definition for singly-linked list. * class ListNode { * int ... 阅读全文

posted @ 2015-04-16 04:33 shini 阅读(81) 评论(0) 推荐(0) 编辑

导航