LeetCode基础知识
文章平均质量分 55
leetcode试题
sxj731533730
江流儿
展开
-
84. Largest Rectangle in Histogram
Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram.Above is a histogram where width of ea...原创 2019-08-31 15:12:45 · 251 阅读 · 0 评论 -
61. Rotate List
Given a linkedlist, rotate the list to the right by k places, where k is non-negative.Example 1:Input: 1->2->3->4->5->NULL, k = 2Output: 4->5->1->2->3->NULLExplana...原创 2019-07-14 15:37:29 · 139 阅读 · 0 评论 -
62. Unique Paths
A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach the bo...原创 2019-07-14 11:06:23 · 151 阅读 · 0 评论 -
64. Minimum Path Sum
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.Note: You can only move either down or right at a...原创 2019-07-14 09:50:32 · 128 阅读 · 0 评论 -
66. Plus One
Given a non-empty array of digitsrepresenting a non-negative integer, plus one to the integer.The digits are stored such that the most significant digit is at the head of the list, and each element...原创 2019-07-14 09:25:03 · 132 阅读 · 0 评论 -
30. Substring with Concatenation of All Words
Hard544928FavoriteShareYou are given a string,s, and a list of words,words, that are all of the same length. Find all starting indices of substring(s) insthat is a concatenation of each word i...翻译 2019-07-04 17:16:34 · 138 阅读 · 0 评论 -
67. Add Binary
Given two binary strings, return their sum (also a binary string).The input strings are both non-empty and contains only characters 1 or0.Example 1:Input: a = "11", b = "1"Output: "100"Exampl...原创 2019-07-13 16:05:19 · 162 阅读 · 0 评论 -
50. Pow(x, n)
Implement pow(x, n), which calculates x raised to the power n (xn).Example 1:Input: 2.00000, 10Output: 1024.00000Example 2:Input: 2.10000, 3Output: 9.26100Example 3:Input: 2.00000, ...原创 2019-01-05 18:31:41 · 293 阅读 · 0 评论 -
49. Group Anagrams
Given an array of strings, group anagrams together.Example:Input: ["eat", "tea", "tan", "ate", "nat", "bat"],Output:[ ["ate","eat","tea"], ["nat"原创 2019-01-05 14:45:19 · 168 阅读 · 0 评论 -
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 matrix d...原创 2019-01-05 12:31:23 · 215 阅读 · 1 评论 -
47. Permutations II
Given a collection of numbers that might contain duplicates, return all possible unique permutations.Example:Input: [1,1,2]Output:[ [1,1,2], [1,2,1], [2,1,1]] class Solution {publi...原创 2019-01-05 12:00:07 · 240 阅读 · 0 评论 -
46. Permutations
Given a collection of distinct integers, return all possible permutations.Example:Input: [1,2,3]Output:[ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1]]class Solution {pu...原创 2019-01-05 11:51:55 · 265 阅读 · 0 评论 -
43. Multiply Strings
Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2, also represented as a string.Example 1:Input: num1 = "2", num2 = "3"Output: "6"Exampl...原创 2019-01-04 00:42:24 · 163 阅读 · 0 评论 -
42. 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.The above elevation map is represented by array...原创 2018-12-23 01:04:57 · 158 阅读 · 0 评论 -
41. First Missing Positive
Given an unsorted integer array, find the smallest missing positive integer.Example 1:Input: [1,2,0]Output: 3Example 2:Input: [3,4,-1,1]Output: 2Example 3:Input: [7,8,9,11,12]Outpu...原创 2018-12-22 15:49:29 · 314 阅读 · 0 评论 -
40. Combination Sum II
Given a collection of candidate numbers (candidates) and a target number (target), find all unique combinations in candidates where the candidate numbers sums to target.Each number in candidates may...原创 2018-12-22 11:53:24 · 277 阅读 · 0 评论 -
60. 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 for n = 3:"123""132""213""231""312""32...原创 2019-07-14 16:18:27 · 193 阅读 · 0 评论 -
53. Maximum Subarray
Given an integer array nums, find the contiguous subarray(containing at least one number) which has the largest sum and return its sum.Example:Input: [-2,1,-3,4,-1,2,1,-5,4],Output: 6Explanatio...原创 2019-07-14 21:23:58 · 169 阅读 · 0 评论 -
89. Gray Code
The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integer n representing the total number of bits in the code, print the sequence of gr...原创 2019-08-31 12:32:41 · 171 阅读 · 0 评论 -
81. Search in Rotated Sorted Array II
Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., [0,0,1,2,2,5,6] might become [2,5,6,0,0,1,2]).You are given a target value to search. If found ...原创 2019-08-31 12:10:16 · 157 阅读 · 0 评论 -
82. Remove Duplicates from Sorted List II
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.Example 1:Input: 1->2->3->3->4->4->5Output: 1->...原创 2019-08-18 15:11:51 · 153 阅读 · 0 评论 -
83. Remove Duplicates from Sorted List
Given a sorted linked list, delete all duplicates such that each element appear only once.Example 1:Input: 1->1->2Output: 1->2Example 2:Input: 1->1->2->3->3Output: 1->...原创 2019-08-18 13:31:17 · 138 阅读 · 0 评论 -
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 yo...原创 2019-08-18 09:15:34 · 169 阅读 · 0 评论 -
80. Remove Duplicates from Sorted Array II
Given a sorted array nums, remove the duplicates in-place such that duplicates appeared at mosttwice and return the new length.Do not allocate extra space for another array, you must do this by mod...原创 2019-08-18 16:00:06 · 146 阅读 · 0 评论 -
71. Simplify Path
Given an absolute path for a file (Unix-style), simplify it. Or in other words, convert it to the canonical path.In a UNIX-style file system, a period .refers to the current directory. Furthermore,...原创 2019-08-01 21:01:18 · 192 阅读 · 0 评论 -
70. Climbing Stairs
You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?Note: Given n will be a positive...原创 2019-08-01 18:42:35 · 148 阅读 · 0 评论 -
63. Unique Paths II
A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach the bo...原创 2019-07-30 19:15:40 · 142 阅读 · 0 评论 -
78. Subsets
Given a set of distinct integers, nums, return all possible subsets (the power set).Note: The solution set must not contain duplicate subsets.Example:Input: nums = [1,2,3]Output:[ [3],[1]...原创 2019-07-29 20:42:14 · 132 阅读 · 0 评论 -
77. Combinations
Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.Example:Input:n = 4, k = 2Output:[ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4],]class Solut...原创 2019-07-29 19:40:35 · 625 阅读 · 0 评论 -
74. Search a 2D Matrix
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted from left to right.The first integer of each row ...原创 2019-07-20 14:15:09 · 146 阅读 · 0 评论 -
75. Sort Colors
Given an array with n objects colored red, white or blue, sort them in-placeso that objects of the same color are adjacent, with the colors in the order red, white and blue.Here, we will use the in...原创 2019-07-20 10:07:11 · 144 阅读 · 0 评论 -
73. Set Matrix Zeroes
Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in-place.Example 1:Input:[[1,1,1],[1,0,1],[1,1,1]]Output:[[1,0,1],[0,0,0],[1,0,1]]Exam...原创 2019-07-20 09:53:17 · 150 阅读 · 0 评论 -
56. Merge Intervals
Given a collection of intervals, merge all overlapping intervals.Example 1:Input: [[1,3],[2,6],[8,10],[15,18]]Output: [[1,6],[8,10],[15,18]]Explanation: Since intervals [1,3] and [2,6] overlaps,...原创 2019-07-16 23:52:58 · 173 阅读 · 0 评论 -
39. Combination Sum
Given a set of candidate numbers (candidates) (without duplicates) and a target number (target), find all unique combinations in candidates where the candidate numbers sums to target.The same repeat...原创 2018-12-21 17:18:36 · 169 阅读 · 0 评论 -
36. Valid Sudoku
Determine if a 9x9 Sudoku board is valid. Only the filled cells need to be validated according to the following rules:Each row must contain the digits 1-9 without repetition. Each column must co...原创 2018-12-06 13:41:44 · 168 阅读 · 0 评论 -
26. Remove Duplicates from Sorted Array
Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this by modifyi...原创 2018-08-30 21:54:11 · 222 阅读 · 0 评论 -
25. Reverse Nodes in k-Group
Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.k is a positive integer and is less than or equal to the length of the linked list. If the number of ...原创 2018-08-30 21:21:52 · 205 阅读 · 0 评论 -
17. Letter Combinations of a Phone Number
Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is giv...原创 2018-08-27 22:25:41 · 285 阅读 · 0 评论 -
24. Swap Nodes in Pairs
Given a linked list, swap every two adjacent nodes and return its head.Example:Given 1->2->3->4, you should return the list as 2->1->4->3.Note:Your algorithm should use only...原创 2018-08-30 20:13:36 · 315 阅读 · 0 评论 -
12. Integer to Roman
Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.Symbol ValueI 1V 5X 10L 50C 100D ...原创 2018-08-17 09:32:48 · 163 阅读 · 0 评论