Leetcode 621. 任务调度器(DAY 91) ---- Leetcode Hot 100(给妹妹送奶茶了 嘻嘻 :) )
发布日期:2021-06-30 22:29:47
浏览次数:2
分类:技术文章
本文共 583 字,大约阅读时间需要 1 分钟。
原题题目
代码实现(首刷纯看解 理解不了题目意思)
class Solution { public: int leastInterval(vector& tasks, int n) { vector v(26,0); int tempmax = -1,count,ret,size = tasks.size(); for(const auto& chr:tasks) { ++v[chr-'A']; if(v[chr-'A'] > tempmax) { ret = chr-'A'; count = 1; } else if(v[chr-'A'] == tempmax) ++count; tempmax = max(tempmax,v[chr-'A']); } ret = max(size,count + (v[ret] - 1) * (n+1)); return ret; }};
转载地址:https://love6.blog.csdn.net/article/details/115919960 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
留言是一种美德,欢迎回访!
[***.207.175.100]2024年04月11日 15时17分08秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
COMP7404 Machine Learing——ROC
2019-04-30
MATLAB与CUDA
2019-04-30
Linux png转jpg (convert命令)
2019-04-30
Ubuntu更新后终端中字体的颜色全是白色
2019-04-30
vscode git
2019-04-30
基于MATLAB的二进制数字调制与解调信号的仿真——2PSK
2019-04-30
基于MATLAB的模拟调制信号与解调的仿真——DSB
2019-04-30
HDU - 1166 敌兵布阵 (树状数组模板题/线段树模板题)
2019-04-30
CodeForces - 761C Dasha and Password (思维 暴力)
2019-04-30
CodeForces - 987C Three displays (暴力/dp)
2019-04-30
牛客国庆集训派对Day4——I 连通块计数(思维)
2019-04-30
牛客国庆集训派对Day5——L 数论之神(找规律/数论)
2019-04-30
CodeForces - 629B Far Relative’s Problem(模拟)
2019-04-30
CodeForces - 456C Boredom (dp)
2019-04-30
CodeForces - 675A Infinite Sequence(简单数论 细节)
2019-04-30
CodeForces - 1042B Vitamins (思维)
2019-04-30
ACM 2013 长沙区域赛 Collision (几何)
2019-04-30