8.1 动态规划二刷
This commit is contained in:
parent
823fb099f9
commit
f417d9d716
@ -11,7 +11,6 @@ package dynamic_programming;
|
|||||||
* 链接:https://leetcode.cn/problems/maximum-length-of-repeated-subarray/
|
* 链接:https://leetcode.cn/problems/maximum-length-of-repeated-subarray/
|
||||||
*/
|
*/
|
||||||
//不会
|
//不会
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dp[i][j] 的定义是:
|
* dp[i][j] 的定义是:
|
||||||
*
|
*
|
||||||
@ -24,6 +23,7 @@ package dynamic_programming;
|
|||||||
* else
|
* else
|
||||||
* dp[i][j] = 0;
|
* dp[i][j] = 0;
|
||||||
*/
|
*/
|
||||||
|
//二刷不会
|
||||||
public class FindLength {
|
public class FindLength {
|
||||||
public int findLength(int[] nums1, int[] nums2) {
|
public int findLength(int[] nums1, int[] nums2) {
|
||||||
int n = nums1.length, m = nums2.length;
|
int n = nums1.length, m = nums2.length;
|
||||||
|
@ -15,6 +15,7 @@ import java.util.Arrays;
|
|||||||
|
|
||||||
* 链接:https://leetcode.cn/problems/longest-continuous-increasing-subsequence/
|
* 链接:https://leetcode.cn/problems/longest-continuous-increasing-subsequence/
|
||||||
*/
|
*/
|
||||||
|
//二刷会做
|
||||||
public class FindLengthOfLCIS {
|
public class FindLengthOfLCIS {
|
||||||
public int findLengthOfLCIS(int[] nums) {
|
public int findLengthOfLCIS(int[] nums) {
|
||||||
int sz=nums.length;
|
int sz=nums.length;
|
||||||
|
@ -13,6 +13,7 @@ package dynamic_programming;
|
|||||||
|
|
||||||
* 链接:https://leetcode.cn/problems/longest-common-subsequence/
|
* 链接:https://leetcode.cn/problems/longest-common-subsequence/
|
||||||
*/
|
*/
|
||||||
|
//二刷会做
|
||||||
public class LongestCommonSubsequence {
|
public class LongestCommonSubsequence {
|
||||||
public int longestCommonSubsequence(String text1, String text2) {
|
public int longestCommonSubsequence(String text1, String text2) {
|
||||||
int n=text1.length(),m=text2.length();
|
int n=text1.length(),m=text2.length();
|
||||||
|
@ -20,7 +20,6 @@ package dynamic_programming;
|
|||||||
public class MaxProfit3 {
|
public class MaxProfit3 {
|
||||||
/**
|
/**
|
||||||
* 一天一共就有五个状态,
|
* 一天一共就有五个状态,
|
||||||
*
|
|
||||||
* 没有操作 (其实我们也可以不设置这个状态)
|
* 没有操作 (其实我们也可以不设置这个状态)
|
||||||
* 第一次持有股票
|
* 第一次持有股票
|
||||||
* 第一次不持有股票
|
* 第一次不持有股票
|
||||||
|
@ -13,6 +13,7 @@ package dynamic_programming;
|
|||||||
* 链接:https://leetcode.cn/problems/best-time-to-buy-and-sell-stock-iv/
|
* 链接:https://leetcode.cn/problems/best-time-to-buy-and-sell-stock-iv/
|
||||||
*/
|
*/
|
||||||
//不会
|
//不会
|
||||||
|
//二刷不会
|
||||||
public class MaxProfit4 {
|
public class MaxProfit4 {
|
||||||
|
|
||||||
public int maxProfit(int k, int[] prices) {
|
public int maxProfit(int k, int[] prices) {
|
||||||
|
@ -11,6 +11,7 @@ package dynamic_programming;
|
|||||||
|
|
||||||
* 链接:https://leetcode.cn/problems/minimum-path-sum/
|
* 链接:https://leetcode.cn/problems/minimum-path-sum/
|
||||||
*/
|
*/
|
||||||
|
//二刷会做
|
||||||
public class MinPathSum {
|
public class MinPathSum {
|
||||||
public int minPathSum(int[][] grid) {
|
public int minPathSum(int[][] grid) {
|
||||||
int r=grid.length;
|
int r=grid.length;
|
||||||
|
@ -16,6 +16,7 @@ import java.util.*;
|
|||||||
|
|
||||||
* 链接:https://leetcode.cn/problems/house-robber-iii/
|
* 链接:https://leetcode.cn/problems/house-robber-iii/
|
||||||
*/
|
*/
|
||||||
|
//二刷会做
|
||||||
public class Rob3 {
|
public class Rob3 {
|
||||||
// 1.递归去偷,超时
|
// 1.递归去偷,超时
|
||||||
public int rob(TreeNode root) {
|
public int rob(TreeNode root) {
|
||||||
|
@ -16,6 +16,7 @@ package dynamic_programming;
|
|||||||
|
|
||||||
* 链接:https://leetcode.cn/problems/unique-paths/
|
* 链接:https://leetcode.cn/problems/unique-paths/
|
||||||
*/
|
*/
|
||||||
|
//二刷会做
|
||||||
public class UniquePaths {
|
public class UniquePaths {
|
||||||
public static int uniquePaths(int m, int n) {
|
public static int uniquePaths(int m, int n) {
|
||||||
int[][] dp = new int[m][n];
|
int[][] dp = new int[m][n];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user