- 博客(29)
- 资源 (5)
- 收藏
- 关注
原创 LeetCode进阶之路(Rotate List)
Given a list, rotate the list to the right by k places, where k is non-negative.For example:Given 1->2->3->4->5->NULL and k = 2,return 4->5->1->2->3->NULL.题目:倒着数k个node,从那开始到结尾和之前那部分对调,那个例子
2016-08-28 21:57:24 351
原创 LeetCode进阶之路(Permutation Sequence)
The set [1,2,3,…,n] contains a total of n! unique permutations.By listing and labeling all of the permutations in order,We get the following sequence (ie, for n = 3):"123""132""213""231""3
2016-08-27 22:19:57 421
原创 LeetCode进阶之路(Spiral Matrix II)
Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order.For example,Given n = 3,You should return the following matrix:[ [ 1, 2, 3 ], [ 8, 9, 4 ], [
2016-08-26 21:57:21 389
原创 LeetCode进阶之路(Length of Last Word)
Given a string s consists 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
2016-08-23 21:42:38 179
原创 LeetCode进阶之路(Insert Interval)
Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals were initially sorted according to their start times.E
2016-08-23 21:30:01 183
原创 LeetCode进阶之路(Merge Intervals)
Given a collection of intervals, merge all overlapping intervals.For example,Given [1,3],[2,6],[8,10],[15,18],return [1,6],[8,10],[15,18].题目:有很多个区间,把有重叠的区间合并。思路:先按照start排序,之后在比较前一个和后一个的e
2016-08-22 22:42:37 224
原创 LeetCode进阶之路(Spiral Matrix)
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 following matrix:[ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ]]
2016-08-21 15:39:16 213
原创 LeetCode进阶之路(Maximum Subarray)
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,-5,4],the contiguous subarray [4,-1,2,1]
2016-08-19 22:27:42 216
原创 LeetCode进阶之路(N-Queens)
The 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 distinct solutions to the n-queens puzzle.
2016-08-19 22:22:39 301
原创 LeetCode进阶之路(Pow(x, n))
Implement pow(x, n).题目:求x^n次方。思路:用递归,但是自己写的时候没考虑仔细,出现了栈溢出的错误(java.lang.StackOverflowError) public double myPow(double x, int n) { if(n == 1){ return x; }
2016-08-16 21:55:20 383
原创 LeetCode进阶之路(Group Anagrams)
Given an array of strings, group anagrams together.For example, given: ["eat", "tea", "tan", "ate", "nat", "bat"], Return:[ ["ate", "eat","tea"], ["nat","tan"], ["bat"]]Note: Al
2016-08-16 21:46:13 234
原创 LeetCode进阶之路(Rotate Image)
You 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 x n的数组反转90度。思路:举个例子观察一下就行了。第一行变成最后一列,第二行变成倒数
2016-08-16 21:36:08 193
原创 LeetCode进阶之路(Permutations II)
Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example,[1,1,2] have the following unique permutations:[ [1,1,2], [1,2,1], [2,1
2016-08-14 17:10:09 289
原创 LeetCode进阶之路(Permutations)
Given a collection of distinct 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,1,2], [3,2,1
2016-08-14 17:04:15 192
原创 LeetCode进阶之路( Jump Game II)
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 maximum jump length at that position.Your goal i
2016-08-12 21:44:05 160
原创 LeetCode进阶之路( Jump Game)
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 maximum jump length at that position.Determine i
2016-08-11 21:29:02 266
原创 LeetCode进阶之路( Trapping Rain Water)
Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.For example, Given [0,1,0,2,1,0,1,3,2,1,2,1]
2016-08-10 22:04:52 201
原创 LeetCode进阶之路( Wildcard Matching)
Implement wildcard pattern matching with support for '?' and '*'.'?' Matches any single character.'*' Matches any sequence of characters (including the empty sequence).The matching should cover t
2016-08-09 23:09:58 213
原创 LeetCode进阶之路( Multiply Strings)
Given two numbers represented as strings, return multiplication of the numbers as a string.Note:The numbers can be arbitrarily large and are non-negative.Converting the input string to integ
2016-08-08 22:48:24 196
原创 LeetCode进阶之路( First Missing Positive)
Given an unsorted integer array, find the first missing positive integer.For example,Given [1,2,0] return 3,and [3,4,-1,1] return 2.Your algorithm should run in O(n) time and uses constant
2016-08-07 22:00:17 194 5
原创 LeetCode进阶之路( Combination Sum II)
Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.Each number in C may only be used once in the combina
2016-08-06 22:49:17 244
原创 LeetCode进阶之路(Combination Sum)
Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.The same repeated number may be chosen from C unlimited numb
2016-08-06 22:28:43 216
原创 LeetCode进阶之路( Count and Say)
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" or 11.11 is read off as "two 1s" or 21.21 is read off as
2016-08-04 22:13:33 177
原创 回溯算法
引言:寻找问题的解的一种可靠的方法是首先列出所有候选解,然后依次检查每一个,在检查完所有或部分候选解后,即可找到所需要的解。理论上,当候选解数量有限并且通过检查所有或部分候选解能够得到所需解时,上述方法是可行的。不过,在实际应用中,很少使用这种方法,因为候选解的数量通常都非常大(比如指数级,甚至是大数阶乘),即便采用最快的计算机也只能解决规模很小的问题。对候选解进行系统检查的方法有多种,其中回
2016-08-03 22:43:16 357
原创 LeetCode进阶之路( Sudoku Solver)
Write a program to solve a Sudoku puzzle by filling the empty cells.Empty cells are indicated by the character '.'.You may assume that there will be only one unique solution.A sudoku
2016-08-02 22:41:07 178
原创 LeetCode进阶之路(Valid Sudoku)
Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled with the character '.'.A partially fille
2016-08-02 22:36:30 153
原创 LeetCode进阶之路( Search Insert Position)
Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in the array.
2016-08-02 22:26:00 156
原创 LeetCode进阶之路( Search for a Range)
Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the order of O(log n).If the target is not found
2016-08-02 00:15:26 156
原创 LeetCode进阶之路(Submission Details)
Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).You are given a target value to search. If found in the array retur
2016-08-01 22:12:36 320
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人