leetcode 200
文章平均质量分 94
Peng_maple
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
[leetcode] 139. Word Break
Word BreakGiven a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequence of one or more dictionary words.N...原创 2019-08-17 11:25:40 · 244 阅读 · 0 评论 -
[leetcode] 76. Minimum Window Substring
Minimum Window SubstringGiven a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).Example:Input: S = “ADOBECODEBANC”, T = “ABC”Ou...原创 2019-07-21 15:09:25 · 164 阅读 · 0 评论 -
[LeetCode] 72. Edit Distance
Edit DistanceGiven two words word1 and word2, find the minimum number of operations required to convert word1 to word2.You have the following 3 operations permitted on a word:Insert a characterDel...原创 2019-07-21 11:46:51 · 143 阅读 · 0 评论 -
[leetcode] 87. Scramble String
Scramble StringGiven a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible representation of s1 = “great”:Given two str...原创 2019-07-31 19:03:07 · 157 阅读 · 0 评论 -
[LeetCode] 78. Subsets && 90. Subsets II
SubsetsGiven 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],[...原创 2019-07-26 20:17:42 · 175 阅读 · 0 评论 -
[LeetCode] 93. Restore IP Addresses
Restore IP AddressesGiven a string containing only digits, restore it by returning all possible valid IP address combinations.Example:Input: “25525511135”Output: [“255.255.11.135”, “255.255.111.3...原创 2019-07-25 20:28:53 · 139 阅读 · 0 评论 -
[LeetCode] 84. Largest Rectangle in Histogram
Largest Rectangle in HistogramGiven 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.Example:I...原创 2019-07-23 16:34:35 · 150 阅读 · 0 评论 -
[LeetCode] 34. Find First and Last Position of Element in Sorted Array Medium
Find First and Last Position of Element in Sorted ArrayGiven an array of integers nums sorted in ascending order, find the starting and ending position of a given target value.Your algorithm’s runti...原创 2019-03-29 13:02:36 · 308 阅读 · 0 评论 -
[LeetCode] 51. N-Queens
N-QueensThe 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...原创 2019-04-02 16:15:46 · 211 阅读 · 0 评论 -
[leetcode] 221. Maximal Square && 85. Maximal Rectangle
Maximal SquareGiven a 2D binary matrix filled with 0’s and 1’s, find the largest square containing only 1’s and return its area.Example:Input:1 0 1 0 01 0 1 1 11 1 1 1 11 0 0 1 0Output: 4解法...原创 2019-07-28 13:18:36 · 317 阅读 · 0 评论 -
[leetcode] 97. Interleaving String
Interleaving StringGiven s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.Example 1:Input: s1 = “aabcc”, s2 = “dbbca”, s3 = “aadbbcbcac”Output: trueExample 2:Input: s1 =...原创 2019-08-01 20:02:54 · 257 阅读 · 0 评论 -
[leetcode] 135. Candy
CandyThere are N children standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requirements:Each child must have at least on...原创 2019-08-16 21:40:49 · 184 阅读 · 0 评论 -
[leetcode] 132.Palindrome Partitioning II
Palindrome Partitioning IIGiven a string s, partition s such that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning of s.Example:Input:...原创 2019-08-16 19:22:14 · 227 阅读 · 0 评论 -
[leetcode] 131. Palindrome Partitioning
Palindrome PartitioningGiven a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s.Example:Input: “aab”Output:[[“a...原创 2019-08-16 16:48:42 · 188 阅读 · 0 评论 -
[leetcode] 128. Longest Consecutive Sequence
Longest Consecutive SequenceGiven an unsorted array of integers, find the length of the longest consecutive elements sequence.Your algorithm should run in O(n) complexity.Example:Input: [100, 4...原创 2019-08-12 21:56:05 · 159 阅读 · 0 评论 -
[leetcode] 130. Surrounded Regions
Surrounded RegionsGiven a 2D board containing ‘X’ and ‘O’ (the letter O), capture all regions surrounded by ‘X’.A region is captured by flipping all 'O’s into 'X’s in that surrounded region.Example...原创 2019-08-16 15:30:42 · 143 阅读 · 0 评论 -
[leetcode] 149. Max Points on a Line
Max Points on a LineGiven n points on a 2D plane, find the maximum number of points that lie on the same straight line.Example 1:Input: [[1,1],[2,2],[3,3]]Output: 3Explanation:^|| o| ...原创 2019-08-24 21:36:53 · 230 阅读 · 0 评论 -
[leetcode] 127. Word Ladder
Word LadderGiven two words (beginWord and endWord), and a dictionary’s word list, find the length of shortest transformation sequence from beginWord to endWord, such that:Only one letter can be chan...原创 2019-08-14 22:19:40 · 142 阅读 · 0 评论 -
[leetcode] 115. Distinct Subsequences
Distinct SubsequencesGiven a string S and a string T, count the number of distinct subsequences of S which equals T.A subsequence of a string is a new string which is formed from the original string...原创 2019-08-10 10:09:09 · 174 阅读 · 0 评论 -
[LeetCode] 33. Search in Rotated Sorted Array
Search in Rotated Sorted ArraySuppose an array sorted in ascending order 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 targ...原创 2019-03-29 10:00:58 · 192 阅读 · 0 评论 -
[LeetCode] 47. Permutations 2
Permutations 2Given 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]]解析相比于Permutations,...原创 2019-04-02 15:02:52 · 215 阅读 · 0 评论 -
[LeetCode] 32. Longest Valid Parentheses
Longest Valid ParenthesesGiven a string containing just the characters ‘(’ and ‘)’, find the length of the longest valid (well-formed) parentheses substring.Example 1:Input: “(()”Output: 2Explan...原创 2019-03-28 21:24:10 · 237 阅读 · 0 评论 -
[LeetCode] 1. Two Sum
Two SumGiven an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may not use th...原创 2019-03-24 14:45:58 · 225 阅读 · 0 评论 -
[LeetCode] 18. 4Sum
4SumGiven an array nums of n integers and an integer target, are there elements a, b, c, and d in nums such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum o...原创 2019-03-27 10:28:36 · 196 阅读 · 0 评论 -
[LeetCode] 16. 3Sum Closest
3Sum ClosestGiven an array nums of n integers and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three integers. You may assume that each...原创 2019-03-27 09:46:33 · 187 阅读 · 0 评论 -
[LeetCode] 15. 3Sum
3SumGiven an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note:The solution set must not c...原创 2019-03-26 20:55:00 · 164 阅读 · 0 评论 -
[LeetCode] 41. First Missing Positive
First Missing PositiveGiven 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...原创 2019-03-30 17:58:29 · 178 阅读 · 0 评论 -
[LeetCode] 37. Sudoku Solver
Sudoku SolverWrite a program to solve a Sudoku puzzle by filling the empty cells.A sudoku solution must satisfy all of the following rules:Each of the digits 1-9 must occur exactly once in each ro...原创 2019-03-29 14:14:21 · 212 阅读 · 0 评论 -
[LeetCode] 10. Regular Expression Matching
Regular Expression MatchingGiven an input string (s) and a pattern §, implement regular expression matching with support for ‘.’ and ‘*’.‘.’ Matches any single character.‘*’ Matches zero or more o...原创 2019-03-25 21:51:33 · 182 阅读 · 0 评论 -
[LeetCode] 5. Longest Palindromic Substring
Longest Palindromic SubstringGiven a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.Example 1:Input: “babad”Output: “bab”Note: “aba” i...原创 2018-12-02 00:10:10 · 179 阅读 · 0 评论 -
[LeetCode] 3. Longest Substring Without Repeating Characters
Longest Substring Without Repeating CharactersGiven a string, find the length of the longest substring without repeating characters.Example 1:Input: “abcabcbb”Output: 3Explanation: The answer is...原创 2019-03-24 15:43:04 · 192 阅读 · 0 评论 -
[LeetCode] 17. Letter Combinations of a Phone Number
Letter Combinations of a Phone NumberGiven 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 ...原创 2019-03-27 15:44:43 · 302 阅读 · 0 评论 -
[LeetCode] 29. Divide Two Integers
Divide Two IntegersGiven two integers dividend and divisor, divide two integers without using multiplication, division and mod operator.Return the quotient after dividing dividend by divisor.The in...原创 2019-03-28 19:03:12 · 171 阅读 · 0 评论 -
[LeetCode] 46. Permutations
PermutationsGiven 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:DFS用一个...原创 2019-04-01 16:39:43 · 174 阅读 · 0 评论 -
[LeetCode] 45. Jump Game2
Jump Game2Given 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 g...原创 2019-04-01 15:36:45 · 228 阅读 · 0 评论 -
[LeetCode] 55. Jump Game
Jump GameGiven 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.Determi...原创 2019-04-01 15:17:54 · 201 阅读 · 0 评论 -
[LeetCode] 123. Best Time to Buy and Sell Stock III
Best Time to Buy and Sell Stock IIISay you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete at most two...原创 2019-04-06 15:59:46 · 184 阅读 · 0 评论 -
[LeetCode] 43. Multiply Strings
Multiply StringsGiven 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”Outp...原创 2019-03-31 23:07:12 · 168 阅读 · 0 评论 -
[LeetCode] 22. Generate Parentheses
Generate ParenthesesGiven n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:[“((()))”,“(()())”,“(())()...原创 2019-03-27 17:16:21 · 164 阅读 · 0 评论 -
[LeetCode] 42. Trapping Rain Water
Trapping Rain WaterGiven 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.Example:Input: [0,1,0,2,1,...原创 2019-03-31 21:25:33 · 214 阅读 · 0 评论
分享