上一页 1 ··· 9 10 11 12 13 14 15 16 17 ··· 21 下一页
摘要: 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 @ 2014-05-29 16:22 erictanghu 阅读(173) 评论(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 @ 2014-05-29 16:21 erictanghu 阅读(85) 评论(0) 推荐(0) 编辑
摘要: Follow up for N-Queens problem.Now, instead outputting board configurations, return the total number of distinct solutions.classSolution{public:inttot... 阅读全文
posted @ 2014-05-29 16:20 erictanghu 阅读(72) 评论(0) 推荐(0) 编辑
摘要: Then-queens puzzle is the problem of placingnqueens on ann×nchessboard such that no two queens attack each other.Given an integern, return all distinc... 阅读全文
posted @ 2014-05-29 16:19 erictanghu 阅读(113) 评论(0) 推荐(0) 编辑
摘要: Implement pow(x,n).classSolution{public:doublepow(doublex,intn){if(n==1)returnx;if(n==-1)return1/x;if(n==0)return1;doubleresult=1;doubletmp=pow(x,n/2)... 阅读全文
posted @ 2014-05-29 16:18 erictanghu 阅读(155) 评论(0) 推荐(0) 编辑
摘要: Given an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.classSolution{public:vectoranagrams(v... 阅读全文
posted @ 2014-05-29 16:18 erictanghu 阅读(91) 评论(0) 推荐(0) 编辑
摘要: You are given annxn2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?classSolution{publi... 阅读全文
posted @ 2014-05-29 16:17 erictanghu 阅读(128) 评论(0) 推荐(0) 编辑
摘要: Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximu... 阅读全文
posted @ 2014-05-29 16:16 erictanghu 阅读(103) 评论(0) 推荐(0) 编辑
摘要: Given a collection of numbers, return all possible permutations.For example,[1,2,3]have the following permutations:[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,... 阅读全文
posted @ 2014-05-29 16:15 erictanghu 阅读(112) 评论(0) 推荐(0) 编辑
摘要: Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example,[1,1,2]have the following unique perm... 阅读全文
posted @ 2014-05-29 16:15 erictanghu 阅读(116) 评论(0) 推荐(0) 编辑
上一页 1 ··· 9 10 11 12 13 14 15 16 17 ··· 21 下一页