原题题目
代码实现(首刷纯看解 理解不了题目意思)
class Solution {
public:
int leastInterval(vector<char>& tasks, int n) {
vector<int> 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;
}
};