8.1 动态规划二刷

This commit is contained in:
zhangsan 2025-08-01 12:52:07 +08:00
parent 823fb099f9
commit f417d9d716
8 changed files with 7 additions and 2 deletions

View File

@ -11,7 +11,6 @@ package dynamic_programming;
* 链接https://leetcode.cn/problems/maximum-length-of-repeated-subarray/
*/
//不会
/**
* dp[i][j] 的定义是
*
@ -24,6 +23,7 @@ package dynamic_programming;
* else
* dp[i][j] = 0;
*/
//二刷不会
public class FindLength {
public int findLength(int[] nums1, int[] nums2) {
int n = nums1.length, m = nums2.length;

View File

@ -15,6 +15,7 @@ import java.util.Arrays;
* 链接https://leetcode.cn/problems/longest-continuous-increasing-subsequence/
*/
//二刷会做
public class FindLengthOfLCIS {
public int findLengthOfLCIS(int[] nums) {
int sz=nums.length;

View File

@ -13,6 +13,7 @@ package dynamic_programming;
* 链接https://leetcode.cn/problems/longest-common-subsequence/
*/
//二刷会做
public class LongestCommonSubsequence {
public int longestCommonSubsequence(String text1, String text2) {
int n=text1.length(),m=text2.length();

View File

@ -20,7 +20,6 @@ package dynamic_programming;
public class MaxProfit3 {
/**
* 一天一共就有五个状态
*
* 没有操作 其实我们也可以不设置这个状态
* 第一次持有股票
* 第一次不持有股票

View File

@ -13,6 +13,7 @@ package dynamic_programming;
* 链接https://leetcode.cn/problems/best-time-to-buy-and-sell-stock-iv/
*/
//不会
//二刷不会
public class MaxProfit4 {
public int maxProfit(int k, int[] prices) {

View File

@ -11,6 +11,7 @@ package dynamic_programming;
* 链接https://leetcode.cn/problems/minimum-path-sum/
*/
//二刷会做
public class MinPathSum {
public int minPathSum(int[][] grid) {
int r=grid.length;

View File

@ -16,6 +16,7 @@ import java.util.*;
* 链接https://leetcode.cn/problems/house-robber-iii/
*/
//二刷会做
public class Rob3 {
// 1.递归去偷超时
public int rob(TreeNode root) {

View File

@ -16,6 +16,7 @@ package dynamic_programming;
* 链接https://leetcode.cn/problems/unique-paths/
*/
//二刷会做
public class UniquePaths {
public static int uniquePaths(int m, int n) {
int[][] dp = new int[m][n];