当前位置:网站首页>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;
}边栏推荐
- Basic use and actual combat sharing of crash tool
- Yocto Technology Sharing Phase 4: Custom add package support
- Swing transformer details-1
- 20220602 Mathematics: Excel table column serial number
- LeetCode - 715. Range 模块(TreeSet) *****
- 20220604数学:x的平方根
- Connect Alibaba cloud servers in the form of key pairs
- My openwrt learning notes (V): choice of openwrt development hardware platform - mt7688
- 3.1 Monte Carlo Methods & case study: Blackjack of on-Policy Evaluation
- CV learning notes - Stereo Vision (point cloud model, spin image, 3D reconstruction)
猜你喜欢

LeetCode - 933 最近的请求次数

LeetCode - 919. 完全二叉树插入器 (数组)

Leetcode-513:找树的左下角值

ADS simulation design of class AB RF power amplifier

What can I do to exit the current operation and confirm it twice?

CV learning notes - camera model (Euclidean transformation and affine transformation)

Octave instructions

Label Semantic Aware Pre-training for Few-shot Text Classification

Yocto Technology Sharing Phase 4: Custom add package support

CV learning notes - deep learning
随机推荐
Vscode markdown export PDF error
Leetcode bit operation
4.1 Temporal Differential of one step
Qcombox style settings
Discrete-event system
Leetcode - 1670 design front, middle and rear queues (Design - two double ended queues)
openEuler kernel 技术分享 - 第1期 - kdump 基本原理、使用及案例介绍
ADS simulation design of class AB RF power amplifier
Deep learning by Pytorch
El table X-axis direction (horizontal) scroll bar slides to the right by default
Opencv+dlib to change the face of Mona Lisa
is_ power_ of_ 2 judge whether it is a multiple of 2
Problems encountered when MySQL saves CSV files
Modelcheckpoint auto save model
2. Elment UI date selector formatting problem
Markdown latex full quantifier and existential quantifier (for all, existential)
Dictionary tree prefix tree trie
【C 题集】of Ⅵ
使用密钥对的形式连接阿里云服务器
3.1 Monte Carlo Methods & case study: Blackjack of on-Policy Evaluation