原题地址:https://leetcode.cn/problems/integer-break/
题解这题某种意义上也是322. 零钱兑换 的变种
只是硬币固定为[1,n]中的所有数,且优先条件为乘积的最大值而非取值次数的最小值
设dp[i]为...
原题地址:https://leetcode.cn/problems/longest-common-subsequence
题解最长公共子序列是一道DP模板题,面对这类问题有相近的思路
开一个二维数组dp,dp[i][j]表示text1.substr...
原题地址:https://leetcode.cn/problems/delete-operation-for-two-strings
题解这题实际上是1143. 最长公共子序列 的变种
让两个字符串相等实际上就是在求两个字符串的公共子序列,而最少的...
原题地址:https://leetcode.cn/problems/number-of-longest-increasing-subsequence/
题解这题在300. 最长递增子序列 的基础上还要求求出最长递增子序列的个数
沿袭在最长递增子序列...
原题地址:https://leetcode.cn/problems/partition-array-for-maximum-sum/
题解参照官方题解思路
设dp[i]为子数组arr[0]——arr[i]的分割最大和,当我们遍历到i时,假设存在一个...
原题地址:https://leetcode.cn/problems/longest-increasing-subsequence/
题解设dp[i]为以nums[i]结束的最长子序列长度
让j遍历[0,i],当nums[j]<nums[i]时...
原题地址:https://leetcode.cn/problems/decode-ways/
题解由于编码最多只到26,因此组合解析的情况最多也只有两个字符
开一个二维数组int[2][s.length()],其中:
dp[0][i]表示第i个字...
原题地址:https://leetcode.cn/problems/count-days-spent-together/
题解通过一个函数dateToIndex将MM-DD格式的日期转换为一年中的第N天,这样我们就能得到Alice和Bob的来往日期...
6335. 二叉树的堂兄弟节点 II原题地址:https://leetcode.cn/problems/cousins-in-binary-tree-ii/
题解堂兄节点是指这一层中除自己和兄弟节点外的其他节点,我们记录下每一层所有节点的和,然后用...
6334. 一个数组所有前缀的分数 - Java 前缀和原题地址:https://leetcode.cn/problems/find-the-score-of-all-prefixes-of-an-array/
题解题目要求返回一个数组,其实我们直...