摘要:
647. 回文子串 //动态规划 // class Solution { // public int countSubstrings(String s) { // char[] a = s.toCharArray(); // int len = a.length; // //dp[i][j]代表区间 阅读全文
摘要:
714. 买卖股票的最佳时机含手续费 class Solution { public int maxProfit(int[] prices, int fee) { int len = prices.length; int[][] dp = new int[len][2]; //两种状态:持有和不持有 阅读全文
摘要:
122. 买卖股票的最佳时机 II // class Solution { // public int maxProfit(int[] prices) { // int n = prices.length; // int[][] dp = new int[n][2]; // dp[0][0] = - 阅读全文
摘要:
377. 组合总和 Ⅳ class Solution { public int combinationSum4(int[] nums, int target) { int[] dp = new int[target + 1]; //求排列 每一层求得是所有物品刚好凑满i的排列数 每个物品无限使用 d 阅读全文
摘要:
474. 一和零 class Solution { public int findMaxForm(String[] strs, int m, int n) { //两个维度的0/1背包 int[][] dp = new int[m + 1][n + 1]; for (String str : str 阅读全文
摘要:
343. 整数拆分 class Solution { public int integerBreak(int n) { if (n < 2) return -1; int dp[] = new int[n + 1]; dp[2] = 1; for (int i = 3; i <= n; i++) { 阅读全文