文章目录
一、括号匹配题目
1.括号配对问题
2.最长括号匹配长度
遍历字符数组,如果如果当前括号能够与栈顶的括号匹配,就出栈,否则将当前索引入栈。
每次均判断当前栈是否为空,如果为空,将ans更新为max(ans, i + 1)
如果不为空,将ans更新为max(ans, i - st.top())
杨daolao的博客:https://zhumenger.top/2019/07/27/数据结构基础/括号配对问题/
3.Longest Regular Bracket Sequence
记录最长的括号子序列和数目
CodeForces - 5C
题解:https://blog.csdn.net/weixin_43772166/article/details/100365652
4.Least Cost Bracket Sequence
CodeForces - 3D
题解:https://blog.csdn.net/weixin_43772166/article/details/100144232
5.Brackets
poj-2955
题解:https://blog.csdn.net/weixin_43772166/article/details/98343855
二、路径记录题目
1.Mysterious Present
CodeForces - 4D
最长上升子序列的路径记录
题解:https://blog.csdn.net/weixin_43772166/article/details/100164132
2.LCIS
CodeForces - 10D
最长公共上升子序列的路径记录,做这道题之前需要先学习一下最长公共上升子序列
题解:https://blog.csdn.net/weixin_43772166/article/details/101026809
三、最大子序和
1.没有长度限制
较为常见的线性DP问题,复杂度为O(n)
https://blog.csdn.net/weixin_43772166/article/details/94610570
2.长度大于等于M
枚举右端点,根据右端点枚举左端点,复杂度为O(n)
https://blog.csdn.net/weixin_43772166/article/details/104051012
3.长度不超过M
单调队列算法,复杂度为O(n)
https://blog.csdn.net/weixin_43772166/article/details/104089451