LeetCode --- 54. Spiral Matrix Feb 9, 2015

 Tags LeetCode , C++ , 数组

题目链接:Spiral MatrixGiven a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.For example,Given the following matrix:[ [ 1... More »

0条评论

LeetCode --- 53. Maximum Subarray Feb 8, 2015

 Tags LeetCode , C++ , 分治 , 数组 , 动态规划

题目链接:Maximum SubarrayFind 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... More »

0条评论

LeetCode --- 52. N-Queens II Feb 7, 2015

 Tags LeetCode , C++ , 回溯

题目链接:N-Queens IIFollow up for N-Queens problem.Now, instead outputting board configurations, return the total number of distinct solutions.这道题的要求是返回N皇后问题总共有多少不同情况。和N-Q... More »

0条评论

LeetCode --- 51. N-Queens Feb 7, 2015

 Tags LeetCode , C++ , 回溯

题目链接:N-QueensThe n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.Given an integer n, return all disti... More »

0条评论

LeetCode --- 50. Pow(x, n) Feb 6, 2015

 Tags LeetCode , C++ , 数学 , 二分搜索

题目链接:Pow(x, n)Implement pow(x, n).这道题的要求是实现pow(x, n)函数。求x的n次幂。直接的暴力思路,将x乘以自身n次即可,时间复杂度O(n)。当n非常大时,计算时间过长。考虑将n转化为二进制数,即n = a0*2^0 + a1*2^1 + a2*2^2 + … + an*2^n。而求x的n次幂... More »

0条评论

LeetCode --- 49. Anagrams Feb 6, 2015

 Tags LeetCode , C++ , 数组

题目链接:AnagramsGiven an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.这道题的要求是给定字符串数组,返回能构成异构的所有字符串。anagram,即异构,... More »

0条评论

LeetCode --- 48. Rotate Image Feb 6, 2015

 Tags LeetCode , C++ , 数组

题目链接:Rotate ImageYou are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?这道题的要求是将n*n的矩阵顺... More »

0条评论

LeetCode --- 47. Permutations II Feb 5, 2015

 Tags LeetCode , C++ , 数组 , 贪心

题目链接:Permutations IIGiven a collection of numbers that might contain duplicates, return all possible unique permutations.For example,[1,1,2] have the following unique ... More »

0条评论

LeetCode --- 46. Permutations Feb 5, 2015

 Tags LeetCode , C++ , 数组 , 贪心

题目链接:PermutationsGiven 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... More »

0条评论

LeetCode --- 45. Jump Game II Feb 4, 2015

 Tags LeetCode , C++ , 数组 , 贪心

题目链接:Jump Game IIGiven 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... More »

0条评论