LeetCode
dldldl1994
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
LeetCode 刷题记录 95. Unique Binary Search Trees II
题目:Given an integer n, generate all structurally unique BST’s (binary search trees) that store values 1 … n.Example:Input: 3Output:[[1,null,3,2],[3,2,null,1],[3,1,null,null,2],[2,1,3],[1,nul...原创 2020-01-13 22:01:18 · 354 阅读 · 0 评论 -
LeetCode 刷题记录 96. Unique Binary Search Trees
题目:Given n, how many structurally unique BST’s (binary search trees) that store values 1 … n?Example:Input: 3Output: 5Explanation:Given n = 3, there are a total of 5 unique BST’s:1 3 ...原创 2020-01-13 19:34:02 · 252 阅读 · 0 评论 -
LeetCode 刷题记录 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...原创 2019-12-11 20:21:17 · 222 阅读 · 0 评论 -
LeetCode 刷题记录 88. Merge Sorted Array
题目:Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note:The number of elements initialized in nums1 and nums2 are m and n respectively.You may assume th...原创 2019-12-09 21:10:34 · 197 阅读 · 0 评论 -
LeetCode 刷题记录 86. Partition List
题目:Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.You should preserve the original relative order of the nodes in each o...原创 2019-12-04 22:38:55 · 173 阅读 · 0 评论 -
LeetCode 刷题记录 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-&g...原创 2019-11-30 13:45:15 · 184 阅读 · 0 评论 -
LeetCode 刷题记录 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-11-27 21:47:10 · 154 阅读 · 0 评论 -
LeetCode 刷题记录 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 foun...原创 2019-11-27 12:46:47 · 169 阅读 · 0 评论 -
LeetCode 刷题记录 80. Remove Duplicates from Sorted Array II
题目:Given a sorted array nums, remove the duplicates in-place such that duplicates appeared at most twice and return the new length.Do not allocate extra space for another array, you must do this by ...原创 2019-11-25 20:06:06 · 190 阅读 · 0 评论 -
LeetCode 刷题记录61. Rotate List
题目:Given a linked list, 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->NULLExpla...原创 2019-11-24 14:02:11 · 185 阅读 · 0 评论 -
LeetCode 刷题记录 90. Subsets II
题目:Given a collection of integers that might contain duplicates, nums, return all possible subsets (the power set).Note: The solution set must not contain duplicate subsets.Example:Input: [1,2,2]...原创 2019-11-23 16:48:44 · 182 阅读 · 0 评论 -
LeetCode 刷题记录 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-11-23 16:31:37 · 160 阅读 · 0 评论 -
LeetCode 刷题记录 79. Word Search
题目:Given a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, where “adjacent” cells are those horizontally or verticall...原创 2019-11-22 22:21:36 · 249 阅读 · 0 评论 -
LeetCode 刷题记录 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],]解法1:递归法c++:class Solut...原创 2019-11-10 16:17:29 · 211 阅读 · 0 评论 -
LeetCode 刷题记录 75. Sort Colors
题目:Given an array with n objects colored red, white or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the order red, white and blue.Here, we will use the...原创 2019-11-07 23:15:59 · 243 阅读 · 0 评论 -
LeetCode 刷题记录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 r...原创 2019-11-04 20:29:34 · 172 阅读 · 0 评论 -
LeetCode 刷题记录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]]Example 2:Input...原创 2019-11-03 22:09:27 · 166 阅读 · 0 评论 -
LeetCode 刷题记录 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. Furthermo...原创 2019-11-02 16:49:34 · 274 阅读 · 0 评论 -
LeetCode 刷题记录 66. Plus One
题目:Given a non-empty array of digits representing 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 elem...原创 2019-10-25 22:28:59 · 221 阅读 · 0 评论 -
LeetCode 刷题记录 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 or 0.Example 1:Input: a = “11”, b = “1”Output: “100”Examp...原创 2019-10-25 21:39:54 · 166 阅读 · 0 评论 -
LeetCode 刷题记录 69. Sqrt(x)
题目:Implement int sqrt(int x).Compute and return the square root of x, where x is guaranteed to be a non-negative integer.Since the return type is an integer, the decimal digits are truncated and on...原创 2019-10-25 21:35:29 · 281 阅读 · 0 评论 -
LeetCode 刷题记录 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 positi...原创 2019-10-25 21:04:22 · 168 阅读 · 0 评论 -
LeetCode 刷题记录 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-10-11 23:01:01 · 222 阅读 · 0 评论 -
LeetCode 刷题记录 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] overlap...原创 2019-10-11 22:29:15 · 189 阅读 · 0 评论 -
LeetCode 刷题记录 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-09-21 14:34:06 · 235 阅读 · 0 评论 -
LeetCode 刷题记录 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 ar...原创 2019-09-20 22:29:18 · 171 阅读 · 0 评论 -
LeetCode 刷题记录 44. Wildcard Matching
题目:Given an input string (s) and a pattern §, implement wildcard pattern matching with support for ‘?’ and ‘*’.‘?’ Matches any single character.‘*’ Matches any sequence of characters (including the...原创 2019-09-23 23:14:06 · 171 阅读 · 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 ...原创 2019-09-25 23:29:18 · 210 阅读 · 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 ...原创 2019-09-26 19:15:52 · 160 阅读 · 0 评论 -
LeetCode 刷题记录 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]]求全排列,没有重复的元素解法1:调用函数...原创 2019-10-03 20:49:48 · 171 阅读 · 0 评论 -
LeetCode 刷题记录 47.PermutationsII
题目: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]]这次有重复需要去重,46题的解法1和解法2无需修改仍可使用解法...原创 2019-10-04 10:21:18 · 213 阅读 · 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 matrix ...原创 2019-10-04 15:18:08 · 137 阅读 · 0 评论 -
LeetCode 刷题记录 49. Group Anagrams
题目:Given an array of strings, group anagrams together.Example:Input: [“eat”, “tea”, “tan”, “ate”, “nat”, “bat”],Output:[[“ate”,“eat”,“tea”],[“nat”,“tan”],[“bat”]]Note:All inputs will be in ...原创 2019-10-04 23:26:32 · 174 阅读 · 0 评论 -
LeetCode 刷题记录 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, -2Outp...原创 2019-10-05 20:19:37 · 311 阅读 · 0 评论 -
LeetCode 刷题记录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 the number of distinct solutions to the n-queens ...原创 2019-10-06 20:29:00 · 196 阅读 · 0 评论 -
LeetCode 刷题记录 51. 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.Ea...原创 2019-10-06 20:50:01 · 219 阅读 · 0 评论 -
LeetCode 刷题记录 53. Maximum Subarray
题目:53. Maximum SubarrayGiven 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...原创 2019-10-07 18:01:18 · 167 阅读 · 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.Example 1:Input:[[ 1, 2, 3 ],[ 4, 5, 6 ],[ 7, 8, 9 ]]Output: [1,2,3,6,9,8,7,4,5]Exa...原创 2019-10-07 21:38:18 · 164 阅读 · 0 评论 -
LeetCode 刷题记录59. Spiral Matrix II
题目:Given a positive integer n, generate a square matrix filled with elements from 1 to n2 in spiral order.Example:Input: 3Output:[[ 1, 2, 3 ],[ 8, 9, 4 ],[ 7, 6, 5 ]]此题与原创 2019-10-07 21:44:34 · 172 阅读 · 0 评论 -
LeetCode 刷题记录58. 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 def...原创 2019-10-07 21:51:42 · 171 阅读 · 0 评论
分享