【075-Sort Colors (颜色排序)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the...
分类:
编程语言 时间:
2015-07-30 07:12:16
阅读次数:
136
【077-Combinations(组合数)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Given two integers n and k, return all possible combinations of k numbers out of 1 … n.
For example,
If n = 4 and k = 2, a solution is...
分类:
编程语言 时间:
2015-07-30 07:11:55
阅读次数:
201
【074-Search a 2D Matrix(搜索二维矩阵)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:
Integers in...
分类:
编程语言 时间:
2015-07-30 07:10:54
阅读次数:
181
【056-Merge Intervals(区间合并)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Given a collection of intervals, merge all overlapping intervals.
For example,
Given [1,3],[2,6],[8,10],[15,18],
return [1,6],[...
分类:
编程语言 时间:
2015-07-29 07:56:58
阅读次数:
153
【054-Spiral Matrix(螺旋矩阵)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.
For example,
Given the foll...
分类:
编程语言 时间:
2015-07-29 07:56:30
阅读次数:
172
【053-Maximum Subarray(最大子数组和)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Find the contiguous subarray within an array (containing at least one number) which has the largest sum.
For example, given the ar...
分类:
编程语言 时间:
2015-07-29 07:55:12
阅读次数:
131
【050-Implement pow(x, n)(求x的n次方)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Implement pow(x, n).
题目大意 求x的n次方。
解题思路 递归求解。
代码实现算法实现类public class Solution { public double myPow(double x, int n) {...
分类:
编程语言 时间:
2015-07-28 06:43:24
阅读次数:
166
【046-Permutations(求排列)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Given a collection of numbers, return all possible permutations.
For example,
[1,2,3] have the following permutations:
[1,2,3], [1,...
分类:
编程语言 时间:
2015-07-28 06:43:13
阅读次数:
129
【038-Count and Say(计数和表述)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 The count-and-say sequence is the sequence of integers beginning as follows:
1, 11, 21, 1211, 111221, ...
1 is read off as "one 1"...
分类:
编程语言 时间:
2015-07-28 06:42:49
阅读次数:
156
【034-Search for a Range(搜索一个范围)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Given a sorted array of integers, find the starting and ending position of a given target value.
Your algorithm’s runtime comple...
分类:
编程语言 时间:
2015-07-27 08:13:21
阅读次数:
328