2015年4月2日

Excel Sheet Column Title

摘要: Given a positive integer, return its corresponding column title as appear in an Excel sheet.For example: 1 -> A 2 -> B 3 -> C ... 26 ->... 阅读全文

posted @ 2015-04-02 09:23 绿树荫 阅读(155) 评论(0) 推荐(1) 编辑

2015年3月30日

Pascal's Triangle

摘要: GivennumRows, generate the firstnumRowsof Pascal's triangle.For example, givennumRows= 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]... 阅读全文

posted @ 2015-03-30 09:55 绿树荫 阅读(171) 评论(0) 推荐(0) 编辑

Flatten Binary Tree to Linked List

摘要: Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattened t... 阅读全文

posted @ 2015-03-30 09:06 绿树荫 阅读(154) 评论(0) 推荐(0) 编辑

2015年3月29日

Partition List

摘要: Given a linked list and a valuex, partition it such that all nodes less thanxcome before nodes greater than or equal tox.You should preserve the origi... 阅读全文

posted @ 2015-03-29 22:11 绿树荫 阅读(101) 评论(0) 推荐(0) 编辑

2015年3月25日

Maximum Subarray

摘要: Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array[−2,1,−3,4,−1,2,1,... 阅读全文

posted @ 2015-03-25 17:34 绿树荫 阅读(185) 评论(1) 推荐(1) 编辑

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?思路一... 阅读全文

posted @ 2015-03-25 17:21 绿树荫 阅读(178) 评论(0) 推荐(1) 编辑

2015年3月24日

Insertion Sort List

摘要: Sort a linked list using insertion sort.思路一:使用一个dummy node,将就的节点插入到新的链表中即可。 1 public ListNode insertionSortList(ListNode head) { 2 ListNode du... 阅读全文

posted @ 2015-03-24 17:00 绿树荫 阅读(175) 评论(0) 推荐(1) 编辑

Combinations

摘要: Given two integersnandk, return all possible combinations ofknumbers out of 1 ...n.For example,Ifn= 4 andk= 2, a solution is:[ [2,4], [3,4], [2,3],... 阅读全文

posted @ 2015-03-24 16:38 绿树荫 阅读(171) 评论(0) 推荐(1) 编辑

Binary Search Tree Iterator

摘要: Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Callingnext()will return the next... 阅读全文

posted @ 2015-03-24 15:27 绿树荫 阅读(125) 评论(0) 推荐(1) 编辑

Longest Valid Parentheses

摘要: Given a string containing just the characters'('and')', find the length of the longest valid (well-formed) parentheses substring.For"(()", the longest... 阅读全文

posted @ 2015-03-24 09:52 绿树荫 阅读(118) 评论(0) 推荐(1) 编辑

导航