![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Leetcode
文章平均质量分 76
sun_sunnybei
这个作者很懒,什么都没留下…
展开
-
Leetcode: 42 Trapping Rain Water
解法1:对于每个位置能储存的水量是,取左面的最高档位,右面的最高档位之中较小的那个,再减去当前的档位即可,所以最直观的解法如下:class Solution { public int trap(int[] height) { int sum = 0,left=0,right=0,now=1,maxl=0,maxr=0; int n = height.原创 2018-01-12 09:57:56 · 145 阅读 · 0 评论 -
Leetcode 55. 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 if you ar...原创 2018-02-07 22:32:39 · 146 阅读 · 0 评论 -
Leetcode 51. N-Queens 52. N-Queens II
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.Each solu...原创 2018-02-07 22:26:46 · 256 阅读 · 0 评论 -
Leetcode 56. 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].根据给出的间隔集合,找出重合的集合进行重合,返回所有不重合的集合。思路:两个间隔不重合的条件是,某个间隔的end小于另一个间...原创 2018-02-07 22:22:32 · 134 阅读 · 0 评论 -
Leetcode 57. 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.Example 1...原创 2018-02-07 22:20:19 · 180 阅读 · 0 评论 -
Leetcode 54. 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 ]]原创 2018-01-28 23:40:55 · 99 阅读 · 0 评论 -
Leetcode 46. Permutations 47. Permutations II
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]]给定一个数组求全排列问题,经原创 2018-01-18 15:05:31 · 152 阅读 · 0 评论 -
Leetcode 53. 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]原创 2018-01-26 22:55:12 · 119 阅读 · 0 评论 -
Leetcode 45. 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 is to rea原创 2018-01-17 23:36:19 · 111 阅读 · 0 评论 -
Leetcode 44. 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 shoul原创 2018-01-17 13:11:29 · 154 阅读 · 0 评论 -
Leetcode 50. Pow(x, n)
Implement pow(x, n).Example 1:Input: 2.00000, 10Output: 1024.00000Example 2:Input: 2.10000, 3Output: 9.26100这道题就是实现pow函数,如果像下列代码一样直接进行迭代,会报StackOverflowError if(n==0)原创 2018-01-24 18:10:23 · 112 阅读 · 0 评论 -
Leetcode 49. 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原创 2018-01-24 11:00:41 · 128 阅读 · 0 评论 -
Leetcode 43. Multiply Strings
Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2.Note:1.The length of both num1 and num2 is 2.Both num1 and num2 contains only digits 0原创 2018-01-16 11:20:24 · 90 阅读 · 0 评论 -
Leetcode 48. Rotate Image
You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Note:You have to rotate the image in-place, which means you have to modify the input 2D ma原创 2018-01-23 15:51:58 · 102 阅读 · 0 评论 -
59. 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 ], [ 7, 6, 5 ]...原创 2018-03-01 11:21:57 · 144 阅读 · 0 评论