上一页 1 ··· 17 18 19 20 21 22 23 24 25 ··· 43 下一页
摘要: Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.For example:Given the below binary tree andsum = 22, 5 / \ 4 8 / / \ 11 13 4 / \ ... 阅读全文
posted @ 2013-08-10 23:38 feiling 阅读(246) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.For example:Given the below binary tree andsum = 22, 5 / \ 4 8 / / \ 11 13 4 / \ / \ 7 2 5 1return[ [5,4,11,2]... 阅读全文
posted @ 2013-08-10 23:35 feiling 阅读(205) 评论(0) 推荐(0) 编辑
摘要: Given a stringsconsists of upper/lower-case alphabets and empty space characters' ', return the length of last word in the string.If the last word does not exist, return 0.Note:A word is defined as a character sequence consists of non-space characters only.For example,Givens="Hello Worl 阅读全文
posted @ 2013-08-09 14:49 feiling 阅读(273) 评论(0) 推荐(0) 编辑
摘要: Given a strings, partitionssuch that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning ofs.For example, givens="aab",Return1since the palindrome partitioning["aa","b"]could be produced using 1 cut.[解题思路]记录所有合法的 阅读全文
posted @ 2013-08-08 15:31 feiling 阅读(886) 评论(0) 推荐(0) 编辑
摘要: Given a strings, partitionssuch that every substring of the partition is a palindrome.Return all possible palindrome partitioning ofs.For example, givens="aab",Return [ ["aa","b"], ["a","a","b"] ]列出字符串分解的题基本都是DFS,本题是找出s所有合数的分解,故i=start在perm 阅读全文
posted @ 2013-08-08 13:54 feiling 阅读(255) 评论(0) 推荐(0) 编辑
摘要: TODO。。。。 阅读全文
posted @ 2013-08-08 13:50 feiling 阅读(215) 评论(0) 推荐(0) 编辑
摘要: Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: Panama"is a palindrome."race a car"isnota palindrome.Note:Have you consider that the string might be empty? This is a good question to 阅读全文
posted @ 2013-08-07 23:25 feiling 阅读(218) 评论(0) 推荐(0) 编辑
摘要: Given an integern, generate a square matrix filled with elements from 1 ton2in spiral order.For example,Givenn=3,You should return the following matrix:[ [ 1, 2, 3 ], [ 8, 9, 4 ], [ 7, 6, 5 ]]java 中是传值的,将count作为返回值返回 1 public static int[][] generateMatrix(int n) { 2 // Start typing your Java... 阅读全文
posted @ 2013-08-07 22:33 feiling 阅读(326) 评论(0) 推荐(0) 编辑
摘要: Given a matrix ofmxnelements (mrows,ncolumns), return all elements of the matrix in spiral order.For example,Given the following matrix:[ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ]]You should return[1,2,3,6,9,8,7,4,5]. 1 public class Solution { 2 public ArrayList spiralOrder(int[][] matrix) { 3 ... 阅读全文
posted @ 2013-08-07 22:15 feiling 阅读(309) 评论(0) 推荐(0) 编辑
摘要: Implement pow(x,n).直接计算会超时TLE 1 public double pow(double x, int n) { 2 // Start typing your Java solution below 3 // DO NOT write main() function 4 if(n == 0) 5 return 1; 6 7 double result = 1; 8 if(n > 0){ 9 while(n > 0){10 ... 阅读全文
posted @ 2013-08-07 20:02 feiling 阅读(325) 评论(0) 推荐(0) 编辑
上一页 1 ··· 17 18 19 20 21 22 23 24 25 ··· 43 下一页