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 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:Leetcode 207. 课程表(DAY 92) ---- Leetcote Hot 100
下一篇:Leetcode 17. 电话号码的字母组合(DAY 90) ---- Leetcode Hot 100

发表评论

最新留言

留言是一种美德,欢迎回访!
[***.207.175.100]2024年04月11日 15时17分08秒