摘要: Given a matrix ofmxnelements (mrows,ncolumns), return all elements of the matrix in spiral order.For example,Given the following matrix:[ [ 1, 2, 3 ],... 阅读全文
posted @ 2016-01-06 15:40 西小贝 阅读(131) 评论(0) 推荐(0)
摘要: 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 @ 2016-01-06 15:38 西小贝 阅读(118) 评论(0) 推荐(0)
摘要: Implement pow(x,n). 1 class Solution { 2 public: 3 double myPow(double x, int n) { 4 if(n>=1;20 x*=x;21 }22 23... 阅读全文
posted @ 2016-01-06 15:37 西小贝 阅读(167) 评论(0) 推荐(0)
摘要: Given an array of strings, group anagrams together.For example, given:["eat", "tea", "tan", "ate", "nat", "bat"],Return:[ ["ate", "eat","tea"], ["na... 阅读全文
posted @ 2016-01-06 15:31 西小贝 阅读(137) 评论(0) 推荐(0)
摘要: Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e.,0 1 2 4 5 6 7might become4 5 6 7 0 1 2).You are given a target value t... 阅读全文
posted @ 2016-01-06 15:29 西小贝 阅读(120) 评论(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 @ 2016-01-06 15:10 西小贝 阅读(136) 评论(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 ... 阅读全文
posted @ 2016-01-06 15:05 西小贝 阅读(145) 评论(0) 推荐(0)