上一页 1 2 3 4 5 6 7 8 ··· 16 下一页
摘要: Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattened t... 阅读全文
posted @ 2014-02-17 13:34 Razer.Lu 阅读(240) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, return thebottom-up level ordertraversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For example:Given binary tree{3,9,20,#,#,15,7}, 3 / \ 9 20 / \ 15 7return its bottom-up level order traversal as:[ [15,7] [9,20], [3],] 解题思... 阅读全文
posted @ 2014-02-17 13:20 Razer.Lu 阅读(194) 评论(0) 推荐(0) 编辑
摘要: Given an indexk, return thekthrow of the Pascal's triangle.For example, givenk= 3,Return[1,3,3,1].Note:Could you optimize your algorithm to use onlyO(k) extra space?滚动数组 + 从后往前计算 避免重复public class Solution { public ArrayList getRow(int rowIndex) { ArrayList res = new ArrayList(); i... 阅读全文
posted @ 2014-02-17 08:12 Razer.Lu 阅读(154) 评论(0) 推荐(0) 编辑
摘要: Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. For "bbbbb" the longest substring is "b", with the length of 1.从 阅读全文
posted @ 2014-02-17 07:31 Razer.Lu 阅读(286) 评论(0) 推荐(0) 编辑
摘要: 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]]第三行开始,每行除边界元素外,每个元素ai都是由ai-1 + ai构成 1 public class Solution { 2 public ArrayList> generate(int numRows) { 3 ArrayList> res = new ArrayLis... 阅读全文
posted @ 2014-02-17 06:45 Razer.Lu 阅读(204) 评论(0) 推荐(0) 编辑
摘要: You are given a string,S, and a list of words,L, that are all of the same length. Find all starting indices of substring(s) in S that is a concatenati... 阅读全文
posted @ 2014-02-17 04:11 Razer.Lu 阅读(213) 评论(0) 推荐(0) 编辑
摘要: Given an arraySofnintegers, find three integers inSsuch that the sum is closest to a given number, target. Return the sum of the three integers. You m... 阅读全文
posted @ 2014-02-17 03:07 Razer.Lu 阅读(200) 评论(0) 推荐(0) 编辑
摘要: Givenn, generate all structurally uniqueBST's(binary search trees) that store values 1...n.For example,Givenn= 3, your program should return all 5 uni... 阅读全文
posted @ 2014-02-17 02:55 Razer.Lu 阅读(166) 评论(0) 推荐(0) 编辑
摘要: Givenn, how many structurally uniqueBST's(binary search trees) that store values 1...n?For example,Givenn= 3, there are a total of 5 unique BST's. 1 3 3 2 1 \ / / / \ \ 3 2 1 1 3 2 / / \ \ 2 1 ... 阅读全文
posted @ 2014-02-17 02:32 Razer.Lu 阅读(212) 评论(0) 推荐(0) 编辑
摘要: Given a string containing just the characters'('and')', find the length of the longest valid (well-formed) parentheses substring.For"(()", the longest valid parentheses substring is"()", which has length = 2.Another example is")()())", where the longest 阅读全文
posted @ 2014-02-17 02:07 Razer.Lu 阅读(225) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 ··· 16 下一页