原题地址:https://leetcode.cn/problems/largest-rectangle-in-histogram/
题解单调栈,分别用两个数组,leftMin[i]记录i左侧第一个高度小于i的下标,rightMin[i]记录i右侧第...
JPEG压缩标准本作品采用知识共享署名-非商业性使用 4.0 国际许可协议 进行许可。节选并译自:https://en.wikipedia.org/wiki/JPEG
要注意的是,Wikipedia给出的JPEG标准描述仍然有疏漏和错误之处,详细准...
原题地址:https://leetcode.cn/problems/maximum-sum-of-two-non-overlapping-subarrays/
题解设DP[i]是子问题:数组[0,i]中两个非重叠子数组的最大和
我们先考虑一些数据的...
原题地址:https://leetcode.cn/problems/last-substring-in-lexicographical-order/
题解参考其他题解
假设子串[i,j]为当前最大子串,若j不为s.length()-1,则必然有[i...
原题地址:https://leetcode.cn/problems/zai-pai-xu-shu-zu-zhong-cha-zhao-shu-zi-lcof/
题解既然这题给出了递增数组这一条件,那么必然是要求我们通过二分查找来实现
因为要统计Ta...
原题地址:
https://leetcode.cn/problems/fu-za-lian-biao-de-fu-zhi-lcof/
https://leetcode.cn/problems/copy-list-with-random-point...
原题地址:https://leetcode.cn/problems/filling-bookcase-shelves/
题解设dp[i]为将前i本书放入书架的最小高度,由于只能按顺序往里填充,我们可以考虑如下几种情况:
第i本书单独占一个书架,高...
原题地址:https://leetcode.cn/problems/word-break/
题解参考官方题解
设dp[i]为s的前i个字符组成的子串(s.substring(0,i+1))是否能被拆分为单词
我们可以从[0,i]遍历一个j,将[0,...
原题地址:https://leetcode.cn/problems/edit-distance/
题解参考官方题解
设dp[i][j]为word1子串[0,i]和word2子串[0,j]之间的编辑距离
假设我们已经知道了dp[i][j-1]为a,...
原题地址:https://leetcode.cn/problems/coin-change/
题解这是一道完全背包DP问题的变种:给定一个容器和数个可取无限次的不同体积的物品,求能放下的最多物品数
而这道题则是给定一个容器和数个可取无限次的不同体积...