
LeetCode算法题
LeetCode算法题,个人刷题记录,辅助记忆
AI门童
望遇名师指路
展开
-
LeetCode算法题之784. Letter Case Permutation(easy)【Python3题解】
题目描述:Given a string S, we can transform every letter individually to be lowercase or uppercase to create another string. Return a list of all possible strings we could create.Examples:Input: S = “a1b2”Output: [“a1b2”, “a1B2”, “A1b2”, “A1B2”]Input: S原创 2020-06-15 22:01:42 · 256 阅读 · 0 评论 -
LeetCode算法题之221. Maximal Square(Medium)【Python3动态规划题解】
题目描述:Given 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题目大意:给定你一个二维的列表,列表中的每个元素都是0,1字符串让你找出只包含字符1的正方形,且其面积最大,输出其面积值解题思路原创 2020-06-04 21:40:16 · 232 阅读 · 0 评论 -
Leetcode算法题之152. Maximum Product Subarray(Medium)【Python3题解】
题目描述:Given an integer array nums, find the contiguous subarray within an array (containing at least one number) which has the largest product.Example 1:Input: [2,3,-2,4]Output: 6Explanation: [2,3] has the largest product 6.Example 2:Input: [-2,0,-1]原创 2020-05-28 23:08:38 · 253 阅读 · 0 评论 -
LeetCode算法题之139. Word Break(Medium)【Python3题解】
题目描述:Given 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.Note:The same word in the dictionary may be reused multiple t原创 2020-05-24 23:07:20 · 265 阅读 · 0 评论 -
LeetCode算法题之120. Triangle(Medium)【Python3题解】
题目描述:Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangleThe minimum path sum from top to bottom is 11 (i.e., 2 + 3 + 5 + 1 = 11).Note:Bo原创 2020-05-20 23:10:50 · 312 阅读 · 0 评论 -
LeetCode算法题之63. Unique Paths II(Medium)【Python3题解】
题目描述: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 bottom-right corner of the grid (marked ‘Finish’ in t原创 2020-05-17 22:13:03 · 252 阅读 · 0 评论 -
LeetCode算法题之64. Minimum Path Sum(Medium)【Python3题解】
题目描述: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 any point in time.Example:Input:[[1,3,1],[1,5,1原创 2020-05-15 23:15:24 · 293 阅读 · 0 评论 -
LeetCode算法题之746. Min Cost Climbing Stairs(easy)【Python3题解】
题目描述:On a staircase, the i-th step has some non-negative cost cost[i] assigned (0 indexed).Once you pay the cost, you can either climb one or two steps. You need to find minimum cost to reach the top of the floor, and you can either start from the step w原创 2020-05-13 22:35:21 · 235 阅读 · 0 评论 -
LeetCode算法题之392. Is Subsequence(easy)【Python3题解】
题目描述:Given a string s and a string t, check if s is subsequence of t.You may assume that there is only lower case English letters in both s and t. t is potentially a very long (length ~= 500,000) string, and s is a short string (<=100).A subsequence原创 2020-05-10 22:24:38 · 198 阅读 · 0 评论 -
LeetCode算法题之55. Jump Game(medium)【Python3题解】
题目描述: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 are able to reach the last index.Example 1:Input原创 2020-05-09 21:39:43 · 293 阅读 · 0 评论 -
LeetCode算法题之62. Unique Paths(medium)【Python3题解】
题目描述: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 t...原创 2020-05-05 22:51:45 · 264 阅读 · 0 评论 -
LeetCode算法题之213. House Robber II(medium)【Python3题解】
题目描述:You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed. All houses at this place are arranged in a circle. That means the first hou...原创 2020-04-29 22:35:01 · 326 阅读 · 0 评论 -
LeetCode算法题之198. House Robber(easy)【Python3动态规划题解】
题目描述:You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent...原创 2020-04-28 23:39:46 · 305 阅读 · 1 评论 -
LeetCode算法题之41. First Missing Positive(hard)【Python3题解】
题目描述: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]Output: 1...原创 2020-04-26 21:19:27 · 192 阅读 · 0 评论 -
LeetCode算法题之66. Plus One(easy)【Python3题解】
题目描述: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 el...原创 2020-04-25 22:41:21 · 201 阅读 · 0 评论 -
LeetCode算法题之35. Search Insert Position(easy)【Python3题解】
题目描述:Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in the arr...原创 2020-04-24 22:37:27 · 160 阅读 · 0 评论 -
LeetCode算法题之309. Best Time to Buy and Sell Stock with Cooldown(medium)【Python3题解】
题目描述:Say 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 as many transactions as you like (ie, buy...原创 2020-04-23 12:50:20 · 231 阅读 · 0 评论 -
LeetCode算法题之122. Best Time to Buy and Sell Stock II(easy)【Python3题解】
题目描述:Say you have an array prices 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 as many transactions as you like (...原创 2020-04-22 22:11:58 · 335 阅读 · 0 评论 -
LeetCode算法题之121. Best Time to Buy and Sell Stock(easy)【Python3动态规划题解】
题目描述:Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (i.e., buy one and sell one share of the st...原创 2020-04-22 11:18:51 · 367 阅读 · 0 评论 -
LeetCode算法题之70. Climbing Stairs(easy)【Python3递归+动态规划题解】
题目描述: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 posi...原创 2020-04-20 21:17:02 · 250 阅读 · 0 评论 -
LeetCode算法题之53. Maximum Subarray(easy)【Python3动态规划题解】
先说大感谢:此篇文章的成型,要特别感谢一个人,labuladong,东哥,算法界一哥,扛把子,得益于他的指点在此也推荐他的公众号,以及他的GitHub仓库,现在已经很火了,公众号:labuladong,GitHub:手把手教你扒LeetCode的裤子,因为很火爆,也很实用,大家应该能找得到,希望看到并感兴趣的朋友,也去学一学好了,开始了题目描述:Given an integer ...原创 2020-04-20 11:33:34 · 243 阅读 · 0 评论 -
LeetCode算法题之16. 3Sum Closest(medium)【Python3题解】
题目描述:Given 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 input ...原创 2020-04-17 10:24:24 · 217 阅读 · 0 评论 -
LeetCode算法题之28. Implement strStr()(easy)【Python3题解】
题目描述:Implement strStr().Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Example 1:Input: haystack = “hello”, needle = “ll”Output: 2Example...原创 2020-04-15 12:15:33 · 168 阅读 · 0 评论 -
LeetCode算法题之32. Longest Valid Parentheses(hard)【Python3题解】
题目描述:Given a string containing just the characters ‘(’ and ‘)’, find the length of the longest valid (well-formed) parentheses substring.Example 1:Input: “(()”Output: 2Explanation: The longest va...原创 2020-04-14 21:20:10 · 191 阅读 · 0 评论 -
LeetCode算法题之10. Regular Expression Matching(hard)【Python3递归法个人详解】
先聊一聊背景如题目所述,这道LeetCode经典算法题,中文名称是正则表达式匹配,如果你已经是刷题的高手,或者还是刚刚刷题的新手,比如我。那么你一定在LeetCode遇到过这道题。那么对于我这个刚刚上路的新手来说,因为这道题的排序是第十位,而我刷题是按照顺序来的,所以很快就遇到了它,结果就是跳过了。。。当时也在网上找过一些答案,基本两种解法最流行吗,其一,是递归;也就是本文将要解释的。其二,...原创 2020-04-13 12:17:07 · 396 阅读 · 0 评论 -
LeetCode算法题之47. Permutations II(medium)【Python3题解】
题目描述: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]]题目大意:给定一个数组,但是包含重复的数字,返回所有的不...原创 2020-04-12 11:02:22 · 200 阅读 · 0 评论 -
LeetCode算法题之46. Permutations(medium)【Python3题解】
题目描述: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]]题目大意:如题目所示,意为排列,置换,也就是将给定的数组...原创 2020-04-12 10:24:35 · 227 阅读 · 0 评论 -
LeetCode算法题之40. Combination Sum II(medium)
题目描述: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 candidate...原创 2020-04-10 12:01:16 · 171 阅读 · 0 评论 -
LeetCode算法题之39. Combination Sum(medium)
题目描述: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 r...原创 2020-04-09 19:50:19 · 216 阅读 · 0 评论 -
LeetCode算法题之22. Generate Parentheses(medium)
题目描述:Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:[“((()))”,“(()())”,“(())()”,“()(())”,“()...原创 2020-04-06 11:21:08 · 197 阅读 · 0 评论 -
LeetCode算法题之17. Letter Combinations of a Phone Number(medium)
题目描述: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) i...原创 2020-04-04 11:03:25 · 211 阅读 · 0 评论 -
LeetCode算法题之31. Next Permutation(medium)
题目描述:Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowest possi...原创 2020-04-03 11:48:23 · 167 阅读 · 0 评论 -
LeetCode算法题之27. Remove Element(easy)
题目描述:Given an array nums and a value val, remove all instances of that value in-place and return the new length.Do not allocate extra space for another array, you must do this by modifying the input...原创 2020-04-02 10:14:24 · 190 阅读 · 0 评论 -
LeetCode算法题之5. Longest Palindromic Substring(medium)
题目描述:Given 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” is also a valid answer.Ex...原创 2020-04-01 16:11:52 · 151 阅读 · 0 评论 -
LeetCode算法题之11. Container With Most Water(medium)
题目描述:Given n non-negative integers a1, a2, …, an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find...原创 2020-03-30 16:58:17 · 197 阅读 · 0 评论 -
LeetCode算法题之18.4Sum
题目描述:Given 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 ...原创 2020-03-29 11:41:34 · 142 阅读 · 0 评论 -
LeetCode算法题之15.3Sum(medium)
题目描述:Given 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 ...原创 2020-03-28 20:40:52 · 225 阅读 · 0 评论 -
LeetCode算法题之12. Integer to Roman(medium)
声明:因本人为AI路上的新手,文章用于辅助个人的整理记忆,理解难免有偏差之处,都是个人拙见,如给其他同僚造成困扰,还请见谅,非常非常非常欢迎私信共同讨论,共同进步题目描述:Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.Symbol ValueI ...原创 2020-03-26 10:09:54 · 173 阅读 · 0 评论 -
LeetCode算法题之8. String to Integer (atoi)(medium)
声明:因本人为AI路上的新手,文章用于辅助个人的整理记忆,理解难免有偏差之处,都是个人拙见,如给其他同僚造成困扰,还请见谅,非常非常非常欢迎私信共同讨论,共同进步题目描述:Implement atoi which converts a string to an integer.The function first discards as many whitespace characters...原创 2020-03-25 11:59:33 · 189 阅读 · 0 评论 -
LeetCode算法题之3. Longest Substring Without Repeating Characters(medium)
声明:因本人为AI路上的新手,文章用于辅助个人的整理记忆,理解难免有偏差之处,都是个人拙见,如给其他同僚造成困扰,还请见谅,非常非常非常欢迎私信共同讨论,共同进步题目描述:Given a string, find the length of the longest substring without repeating characters.Example 1:Input: “abcab...原创 2020-03-24 11:35:12 · 145 阅读 · 0 评论