LeetCode
Fayedy
这个作者很懒,什么都没留下…
展开
-
【LeetCode】解题44:Wildcard Matching(动态规划解法)
LeetCode解题 44:Wildcard Matching(动态规划解法)Problem 44: Wildcard Matching [Hard]解题思路Solution (Java)Problem 44: Wildcard Matching [Hard]Given an input string (s) and a pattern (p), implement wildcard patt...原创 2020-04-27 14:52:34 · 293 阅读 · 0 评论 -
【LeetCode】解题32:Longest Valid Parentheses(多解法:栈+动态规划+计数器)
LeetCode解题 32:Longest Valid Parentheses(多解法:栈+动态规划+计数器)Problem 32: Longest Valid Parentheses [Hard]解题思路1. 栈2. 动态规划3. 计数器Solution (Java)Problem 32: Longest Valid Parentheses [Hard]Given a string cont...原创 2020-04-27 01:00:42 · 245 阅读 · 0 评论 -
【LeetCode】解题10:Regular Expression Matching(动态规划解法)
LeetCode解题 10:Regular Expression Matching(动态规划解法)Problem 10: Regular Expression Matching [Hard]解题思路Solution (Java)Problem 10: Regular Expression Matching [Hard]Given an input string (s) and a patter...原创 2020-04-25 01:55:07 · 309 阅读 · 0 评论 -
【LeetCode】解题5:Longest Palindromic Substring(多解法:动态规划+中心扩散)
LeetCode解题 152:Longest Palindromic SubstringProblem 152: Longest Palindromic Substring [Medium]解题思路Solution (Java)Problem 152: Longest Palindromic Substring [Medium]Given an integer array nums, find...原创 2020-04-21 00:19:21 · 156 阅读 · 0 评论 -
【LeetCode】解题152:Maximum Product Subarray
LeetCode解题 152:Maximum Product SubarrayProblem 152: Maximum Product Subarray [Medium]解题思路Solution (Java)Problem 152: Maximum Product Subarray [Medium]Given an integer array nums, find the contiguous...原创 2020-04-20 00:03:34 · 153 阅读 · 0 评论 -
【LeetCode】解题128:Longest Consecutive Sequence
LeetCode解题 128:Longest Consecutive SequenceProblem 128: Longest Consecutive Sequence [Hard]解题思路Solution (Java)Problem 128: Longest Consecutive Sequence [Hard]Given an unsorted array of integers, fin...原创 2020-04-19 00:34:27 · 164 阅读 · 0 评论 -
【LeetCode】解题126:Word Ladder II(BFS算法)
LeetCode解题 126:Word Ladder II(BFS算法)Problem 126: Word Ladder II [Hard]解题思路Solution (Java)修改过程Problem 126: Word Ladder II [Hard]Given two words (beginWord and endWord), and a dictionary’s word list, ...原创 2020-04-18 01:25:00 · 630 阅读 · 0 评论 -
【LeetCode】解题714:Best Time to Buy and Sell Stock with Transaction Fee(动态规划)
LeetCode解题 714:Best Time to Buy and Sell Stock with Transaction Fee (动态规划)Problem 714: Best Time to Buy and Sell Stock with Transaction Fee [Medium]解题思路Solution (Java)Problem 714: Best Time to Buy an...原创 2020-04-16 17:35:58 · 242 阅读 · 0 评论 -
【LeetCode】解题309:Best Time to Buy and Sell Stock with Cooldown(动态规划)
LeetCode解题 309:Best Time to Buy and Sell Stock with Cooldown (动态规划)Problem 309: Best Time to Buy and Sell Stock with Cooldown [Medium]解题思路Solution (Java)修改过程Problem 309: Best Time to Buy and Sell Sto...原创 2020-04-16 00:12:34 · 222 阅读 · 0 评论 -
【LeetCode】解题188:Best Time to Buy and Sell Stock IV(动态规划)
LeetCode解题 188:Best Time to Buy and Sell Stock IV (动态规划)Problem 188: Best Time to Buy and Sell Stock IV [Hard]解题思路Solution (Java)修改过程Problem 188: Best Time to Buy and Sell Stock IV [Hard]Say you hav...原创 2020-04-15 14:44:24 · 456 阅读 · 0 评论 -
【LeetCode】解题123:Best Time to Buy and Sell Stock III(动态规划)
LeetCode解题 123:Best Time to Buy and Sell Stock III (动态规划)Problem 123: Best Time to Buy and Sell Stock III [Hard]解题思路I. O(2n)时间+O(3n)空间II. O(2n)时间+O(n)空间III. O(n)时间+O(4)空间Solution (Java)Problem 123: B...原创 2020-04-15 02:24:24 · 360 阅读 · 0 评论 -
【LeetCode】解题122:Best Time to Buy and Sell Stock II
LeetCode解题 122:Best Time to Buy and Sell Stock II Problem 122: Best Time to Buy and Sell Stock II [Easy]解题思路Solution (Java)Problem 122: Best Time to Buy and Sell Stock II [Easy]Say you have an array...原创 2020-04-12 22:35:46 · 252 阅读 · 0 评论 -
【LeetCode】解题121:Best Time to Buy and Sell Stock
LeetCode解题 121:Best Time to Buy and Sell Stock Problem 121: Best Time to Buy and Sell Stock [Easy]解题思路Solution (Java)Problem 121: Best Time to Buy and Sell Stock [Easy]Say you have an array for whic...原创 2020-04-11 20:39:43 · 221 阅读 · 0 评论 -
【LeetCode】解题120:Triangle
LeetCode解题 120:Triangle Problem 120: Triangle [Medium]解题思路Solution (Java)Problem 120: Triangle [Medium]Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjac...原创 2020-04-11 02:00:24 · 184 阅读 · 0 评论 -
【LeetCode】解题119:Pascal's Triangle II
LeetCode解题 118:Pascal's Triangle II Problem 118: Pascal's Triangle II [Easy]解题思路Solution (Java)Problem 118: Pascal’s Triangle II [Easy]Given a non-negative index k where k ≤ 33, return the kth index...原创 2020-04-10 02:06:46 · 342 阅读 · 0 评论 -
【LeetCode】解题118:Pascal's Triangle
LeetCode解题 118:Pascal's Triangle Problem 118: Pascal's Triangle [Easy]解题思路Solution (Java)Problem 118: Pascal’s Triangle [Easy]Given a non-negative integer numRows, generate the first numRows of Pasc...原创 2020-04-08 23:29:40 · 198 阅读 · 0 评论 -
【LeetCode】解题105:Construct Binary Tree from Preorder and Inorder Traversal
LeetCode解题 105:Construct Binary Tree from Preorder and Inorder Traversal Problem 105: Construct Binary Tree from Preorder and Inorder Traversal [Medium]解题思路Solution (Java)Problem 105: Construct Binar...原创 2020-04-06 18:47:58 · 142 阅读 · 0 评论 -
【LeetCode】解题90:Subsets II
LeetCode解题 90:Subsets II Problem 90: Subsets II [Medium]解题思路Solution (Java)修改过程Problem 90: Subsets II [Medium]Given a collection of integers that might contain duplicates, nums, return all possible ...原创 2020-04-05 17:45:48 · 151 阅读 · 0 评论 -
【LeetCode】解题85:Maximal Rectangle
LeetCode解题 85:Maximal Rectangle Problem 85: Maximal Rectangle [Hard]解题思路Solution (Java)Problem 85: Maximal Rectangle [Hard]Given a 2D binary matrix filled with 0’s and 1’s, find the largest rectangl...原创 2020-04-03 20:50:04 · 172 阅读 · 0 评论 -
【LeetCode】解题84:Largest Rectangle in Histogram
LeetCode解题 84:Largest Rectangle in Histogram Problem 84: Largest Rectangle in Histogram [Hard]解题思路1. 分治法2. 栈Solution (Java)修改过程Problem 84: Largest Rectangle in Histogram [Hard]Given n non-negative i...原创 2020-04-03 02:56:39 · 200 阅读 · 0 评论 -
【LeetCode】解题81:Search in Rotated Sorted Array II
LeetCode解题 81:Search in Rotated Sorted Array II Problem 81: Search in Rotated Sorted Array II [Medium]解题思路Solution (Java)Problem 81: Search in Rotated Sorted Array II [Medium]Suppose an array sorted...原创 2020-04-01 23:00:39 · 174 阅读 · 0 评论 -
【LeetCode】解题80:Remove Duplicates from Sorted Array II
LeetCode解题 80:Remove Duplicates from Sorted Array II Problem 80: Remove Duplicates from Sorted Array II [Medium]解题思路Solution (Java)修改过程Problem 80: Remove Duplicates from Sorted Array II [Medium]Give...原创 2020-03-31 21:33:26 · 243 阅读 · 0 评论 -
【LeetCode】解题79:Word Search
LeetCode解题 79:Word Search Problem 79: Word Search [Medium]解题思路Solution (Java)修改过程Problem 79: Word Search [Medium]Given a 2D board and a word, find if the word exists in the grid.The word can be con...原创 2020-03-31 02:24:05 · 220 阅读 · 0 评论 -
【LeetCode】解题78:Subsets
LeetCode解题 78:Subsets Problem 78: Subsets [Medium]解题思路Solution (Java)修改过程Problem 78: Subsets [Medium]Given a set of distinct integers, nums, return all possible subsets (the power set).Note: The so...原创 2020-03-29 20:32:40 · 139 阅读 · 0 评论 -
【LeetCode】解题75:Sort Colors
LeetCode解题 75:Sort Colors Problem 75: Sort Colors [Medium]解题思路Solution (Java)修改过程Problem 75: Sort Colors [Medium]Given an array with n objects colored red, white or blue, sort them in-place so that ...原创 2020-03-29 00:08:04 · 174 阅读 · 0 评论 -
【LeetCode】解题74:Search a 2D Matrix
LeetCode解题 74:Search a 2D Matrix Problem 74: Search a 2D Matrix [Medium]解题思路Solution (Java)Problem 74: Search a 2D Matrix [Medium]Write an efficient algorithm that searches for a value in an m x n m...原创 2020-03-27 15:15:27 · 147 阅读 · 0 评论 -
【LeetCode】解题73:Set Matrix Zeroes
LeetCode解题 73:Set Matrix Zeroes Problem 73: Set Matrix Zeroes [Medium]解题思路Solution (Java)Problem 73: Set Matrix Zeroes [Medium]Given a m x n matrix, if an element is 0, set its entire row and column...原创 2020-03-25 14:39:57 · 137 阅读 · 0 评论 -
【LeetCode】解题66:Plus One
LeetCode解题 66:Plus One Problem 66: Plus One [Easy]解题思路Solution (Java)修改过程Problem 66: Plus One [Easy]Given a non-empty array of digits representing a non-negative integer, plus one to the integer.Th...原创 2020-03-22 17:12:13 · 172 阅读 · 0 评论 -
【LeetCode】解题64:Minimum Path Sum
LeetCode解题 64:Minimum Path Sum Problem 64: Minimum Path Sum [Medium]解题思路Solution (Java)Problem 64: Minimum Path Sum [Medium]Given a m x n grid filled with non-negative numbers, find a path from top ...原创 2020-03-21 17:46:13 · 205 阅读 · 0 评论 -
【LeetCode】解题63:Unique Paths II
LeetCode解题 63:Unique Paths II Problem 63: Unique Paths II [Medium]解题思路Solution (Java)Problem 63: Unique Paths II [Medium]A robot is located at the top-left corner of a m x n grid (marked ‘Start’ in ...原创 2020-03-20 18:27:53 · 198 阅读 · 0 评论 -
【LeetCode】解题62:Unique Paths
LeetCode解题 62:Unique Paths Problem 62: Unique Paths [Medium]解题思路Solution (Java)Problem 62: Unique Paths [Medium]A robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagr...原创 2020-03-20 01:12:34 · 159 阅读 · 0 评论 -
【LeetCode】解题59:Spiral Matrix II
LeetCode解题 59:Spiral Matrix II Problem 59: Spiral Matrix II [Medium]解题思路Solution (Java)Problem 59: Spiral Matrix II [Medium]Given a positive integer n, generate a square matrix filled with elements ...原创 2020-03-17 14:51:42 · 167 阅读 · 0 评论 -
【LeetCode】解题57:Insert Interval
LeetCode解题 57:Insert Interval Problem 57: Insert Interval [Hard]解题思路Solution (Java)Problem 57: Insert Interval [Hard]Given a set of non-overlapping intervals, insert a new interval into the interval...原创 2020-03-17 00:33:17 · 192 阅读 · 0 评论 -
【LeetCode】解题56:Merge Intervals
LeetCode解题 56:Merge Intervals Problem 56: Merge Intervals [Medium]解题思路Solution (Java)Problem 56: Merge Intervals [Medium]Given a collection of intervals, merge all overlapping intervals.Example 1:...原创 2020-03-16 01:02:22 · 157 阅读 · 0 评论 -
【LeetCode】解题55:Jump Game
LeetCode解题 55:Jump Game Problem 55: Jump Game [Medium]解题思路Solution (Java)Problem 55: Jump Game [Medium]Given an array of non-negative integers, you are initially positioned at the first index of the...原创 2020-03-14 23:43:17 · 197 阅读 · 1 评论 -
【LeetCode】解题54:Spiral Matrix
LeetCode解题 54:Spiral Matrix Problem 54: Spiral Matrix [Medium]解题思路Solution (Java)修改过程Problem 54: Spiral Matrix [Medium]Given a matrix of m x n elements (m rows, n columns), return all elements of th...原创 2020-03-14 01:19:55 · 157 阅读 · 0 评论 -
【LeetCode】解题53:Maximum Subarray
LeetCode解题 53:Maximum Subarray Problem 53: Maximum Subarray [Easy]解题思路Solution (Java)Problem 53: Maximum Subarray [Easy]Given an integer array nums, find the contiguous subarray (containing at least...原创 2020-03-13 00:25:22 · 208 阅读 · 0 评论 -
【LeetCode】解题48:Rotate Image
LeetCode解题 48:Rotate Image Problem 48: Rotate Image [Medium]解题思路Solution (Java)Problem 48: Rotate Image [Medium]You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees...原创 2020-03-10 22:47:04 · 142 阅读 · 0 评论 -
【LeetCode】解题45:Jump Game II
LeetCode解题 45:Jump Game II Problem 45: Jump Game II [Hard]解题思路1. 暴力搜索(不剪枝)2. 贪心算法Solution (Java)修改过程Problem 45: Jump Game II [Hard]Given an array of non-negative integers, you are initially position...原创 2020-03-10 01:38:17 · 174 阅读 · 0 评论 -
【LeetCode】解题42:Trapping Rain Water
LeetCode解题 42:Trapping Rain Water Problem 42: Trapping Rain Water [Hard]解题思路Solution (Java)修改过程Problem 42: Trapping Rain Water [Hard]Given n non-negative integers representing an elevation map where...原创 2020-03-09 01:38:09 · 178 阅读 · 0 评论