随笔分类 -  单调栈 / 队列

摘要:思路分析 : 比较好想到的是用尺取法来做,但是数据有负数,如何还是按正常的尺取法做,那么得到的答案有可能不是最优解 那么我们可以用单调队列来求解,单调队列中保存前缀和 代码示例: class Solution { public: int shortestSubarray(vector<int>& n 阅读全文
posted @ 2021-11-12 22:12 楼主好菜啊 阅读(46) 评论(0) 推荐(1) 编辑
摘要:给定一个以字符串表示的非负整数 num,移除这个数中的 k 位数字,使得剩下的数字最小。 注意: num 的长度小于 10002 且 ≥ k。num 不会包含任何前导零。示例 1 : 输入: num = "1432219", k = 3输出: "1219"解释: 移除掉三个数字 4, 3, 和 2 阅读全文
posted @ 2020-11-15 10:40 楼主好菜啊 阅读(457) 评论(0) 推荐(0) 编辑
摘要:262144K Alice has a magic array. She suggests that the value of a interval is equal to the sum of the values in the interval, multiplied by the smalle 阅读全文
posted @ 2019-05-02 20:27 楼主好菜啊 阅读(299) 评论(0) 推荐(0) 编辑
摘要:The only difference between easy and hard versions is the constraints. Vova likes pictures with kittens. The news feed in the social network he uses c 阅读全文
posted @ 2018-11-21 21:50 楼主好菜啊 阅读(213) 评论(0) 推荐(0) 编辑
摘要:链接:https://ac.nowcoder.com/acm/contest/223/C来源:牛客网 题目描述 给出长度为n的序列a,其中第i个元素为,定义区间(l,r)的价值为 请你计算出 输入描述: 第一行输入数据组数T对于每组数据,第一行为一个整数n,表示序列长度接下来一行有n个数,表示序列内 阅读全文
posted @ 2018-11-02 12:28 楼主好菜啊 阅读(3998) 评论(0) 推荐(1) 编辑
摘要:链接:https://www.nowcoder.com/acm/contest/131/B来源:牛客网 题目描述 矩阵 M 包含 R 行 C 列,第 i 行第 j 列的值为 Mi,j。 请寻找一个子矩阵,使得这个子矩阵的和最大,且满足以下三个条件: 子矩阵的行数不能超过 X 行。 子矩阵的列数不能超 阅读全文
posted @ 2018-07-29 00:02 楼主好菜啊 阅读(232) 评论(0) 推荐(0) 编辑
摘要:Given a m-by-n (0,1)-matrix, of all its submatrices of all 1’s which is the largest? By largest we mean that the submatrix has the most elements. Inpu 阅读全文
posted @ 2018-07-26 08:43 楼主好菜啊 阅读(1088) 评论(0) 推荐(0) 编辑
摘要:推荐博客 : https://blog.csdn.net/zuzhiang/article/details/78134247 单调栈、队列只需满足两个条件即可,序列是单调的,并且符合栈和队列的特性。 实现: 例如实现一个单调递增的栈,比如现在有一组数10,3,7,4,12。从左到右依次入栈,则如果栈 阅读全文
posted @ 2018-07-25 18:49 楼主好菜啊 阅读(180) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示