随笔分类 - DP
[Leetcode 5] 最长回文子串Longest Palindromic Substring
摘要:问题 求最长回文子串,即左右对称 Given a string s, return the longest palindromic substring in s. Example 1: Input: s = "babad" Output: "bab" Note: "aba" is also a va
阅读全文
[Leetcode 152]最大乘积子串Maximum Product Subarray 踩坑
摘要:【题目】 一串int数组中找到乘积最大的子串,子串必须连续,返回成绩ans Given an integer array nums, find a contiguous non-empty subarray within the array that has the largest product,
阅读全文
[Leetcode 198/213/337]强盗偷家 House Robber 三题DP整理
摘要:【题目1】 此系列有三题,都是强盗偷家不能偷相邻邻居,否则会被发现。问最多能偷多少钱 You are a professional robber planning to rob houses along a street. Each house has a certain amount of mon
阅读全文
[Leetcode 162]爬楼梯最小耗费Min Cost Climbing Stairs**
摘要:【题目】 爬楼梯变式,可以上1/2台阶,每个台阶有cost,求爬上去的最小耗费 You are given an integer array cost where cost[i] is the cost of ith step on a staircase. Once you pay the cos
阅读全文
[Leetcode 718]最长重复子数列Maximum Length of Repeated Subarray
摘要:【题目】 两个数组,求他们最长的相同子串长度,数组长度不一定相同 Given two integer arrays nums1 and nums2, return the maximum length of a subarray that appears in both arrays. Exampl
阅读全文
[Leetcode 72]编辑距离 Edit Distance
摘要:【题目】 Given two words word1 and word2, find the minimum number of operations required to convert word1 to word2. You have the following 3 operations pe
阅读全文
[Leetcode221]最大面积 Maximal Square
摘要:【题目】 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: 【思路】 【代码】
阅读全文
[Leetcode 376]摇摆序列 Wiggle Subsequence
摘要:【题目】 A sequence of numbers is called a wiggle sequence if the differences between successive numbers strictly alternate between positive and negative.
阅读全文
[Leetcode 62]机器人走路Unique Path 动态规划
摘要:【题目】 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
阅读全文
[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 y
阅读全文
[leetcode53]最长子数组 Maximum Subarray Kadane's算法
摘要:【题目】 Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. Example:
阅读全文
[Leetcode 44]通配符匹配Wildcard Matching
摘要:【题目】 匹配通配符*,?,DP动态规划,重点是*的两种情况 想象成两个S、P长度的字符串,P匹配S。 S中不会出现通配符。 【条件】 (1)P=null,S=null,TRUE (2)P=null,S!=null,P必然无法匹配S,FALSE。 (3)P[i]=“*” 的TRUE/FALSE状态等
阅读全文
浙公网安备 33010602011771号