当前位置:网站首页>20220610 other: Task Scheduler
20220610 other: Task Scheduler
2022-07-03 10:12:00 【Seeyouagain】
Title Description : Here's an array of characters for you tasks It means CPU List of tasks to be performed . Each letter represents a different kind of task . Tasks can be performed in any order , And every task can be in 1 In unit time . At any unit time ,CPU Can complete a task , Or on standby .
However , Two Same kind There must be integer length between tasks of n The cooling time of , So at least there's continuity n In units of time CPU On different missions , Or on standby .
You need to calculate what it takes to complete all the tasks The shortest time .
coded :
public static int leastInterval(char[] tasks, int n) {
int maxSize = 0, maxCount = 0;
int hash[] = new int[26];
int length = tasks.length;
for (int i=0; i< length; i++) {
hash[tasks[i] - 'A']++;
if (hash[tasks[i] - 'A'] > maxSize) {
maxSize = hash[tasks[i] - 'A'];
}
}
for (int i=0; i<26; i++) {
if (hash[i] == maxSize) maxCount++;
}
return length > (maxSize-1)*(n+1)+maxCount ? length : (maxSize-1)*(n+1)+maxCount;
}边栏推荐
- Opencv feature extraction sift
- Google browser plug-in recommendation
- openCV+dlib實現給蒙娜麗莎換臉
- CV learning notes - BP neural network training example (including detailed calculation process and formula derivation)
- 2021-11-11 standard thread library
- 4G module designed by charging pile obtains signal strength and quality
- CV learning notes - camera model (Euclidean transformation and affine transformation)
- 20220602数学:Excel表列序号
- LeetCode - 919. 完全二叉树插入器 (数组)
- Leetcode-106:根据中后序遍历序列构造二叉树
猜你喜欢

LeetCode - 1670 設計前中後隊列(設計 - 兩個雙端隊列)

2021-10-27

Leetcode 300 最长上升子序列

2.2 DP: Value Iteration & Gambler‘s Problem

My notes on intelligent charging pile development (II): overview of system hardware circuit design

The underlying principle of vector

ADS simulation design of class AB RF power amplifier

Discrete-event system

Opencv feature extraction - hog
![[C question set] of Ⅵ](/img/49/eb31cd26f7efbc4d57f17dc1321092.jpg)
[C question set] of Ⅵ
随机推荐
On the problem of reference assignment to reference
Leetcode - 1670 conception de la file d'attente avant, moyenne et arrière (conception - deux files d'attente à double extrémité)
Stm32 NVIC interrupt priority management
Opencv gray histogram, histogram specification
20220610其他:任务调度器
Basic use and actual combat sharing of crash tool
『快速入门electron』之实现窗口拖拽
Opencv note 21 frequency domain filtering
CV learning notes alexnet
The data read by pandas is saved to the MySQL database
LeetCode - 508. 出现次数最多的子树元素和 (二叉树的遍历)
Vgg16 migration learning source code
yocto 技術分享第四期:自定義增加軟件包支持
QT self drawing button with bubbles
openEuler kernel 技術分享 - 第1期 - kdump 基本原理、使用及案例介紹
Modelcheckpoint auto save model
2021-10-27
LeetCode - 919. Full binary tree inserter (array)
ADS simulation design of class AB RF power amplifier
Wireshark use