当前位置:网站首页>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;
}边栏推荐
- CV learning notes convolutional neural network
- Openeuler kernel technology sharing - Issue 1 - kdump basic principle, use and case introduction
- Stm32 NVIC interrupt priority management
- Anaconda安装包 报错packagesNotFoundError: The following packages are not available from current channels:
- 2021-10-27
- Leetcode-100:相同的树
- Implementation of "quick start electronic" window dragging
- [C question set] of Ⅵ
- Opencv feature extraction sift
- Adaptiveavgpool1d internal implementation
猜你喜欢

LeetCode - 508. 出现次数最多的子树元素和 (二叉树的遍历)

CV learning notes - scale invariant feature transformation (SIFT)

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

Leetcode - 1670 design front, middle and rear queues (Design - two double ended queues)

One click generate traffic password (exaggerated advertisement title)

『快速入门electron』之实现窗口拖拽

Leetcode-513:找树的左下角值

LeetCode - 900. RLE 迭代器

波士顿房价预测(TensorFlow2.9实践)

Connect Alibaba cloud servers in the form of key pairs
随机推荐
After clicking the Save button, you can only click it once
CV learning notes ransca & image similarity comparison hash
LeetCode - 1670 设计前中后队列(设计 - 两个双端队列)
YOLO_ V1 summary
LeetCode - 673. 最长递增子序列的个数
Leetcode - 460 LFU cache (Design - hash table + bidirectional linked hash table + balanced binary tree (TreeSet))*
4G module initialization of charge point design
Opencv image rotation
20220604数学:x的平方根
01 business structure of imitation station B project
(1) What is a lambda expression
Positive and negative sample division and architecture understanding in image classification and target detection
Opencv note 21 frequency domain filtering
CV learning notes - Stereo Vision (point cloud model, spin image, 3D reconstruction)
使用密钥对的形式连接阿里云服务器
LeetCode - 460 LFU 缓存(设计 - 哈希表+双向链表 哈希表+平衡二叉树(TreeSet))*
Opencv feature extraction sift
Leetcode interview question 17.20 Continuous median (large top pile + small top pile)
20220603 Mathematics: pow (x, n)
Basic use and actual combat sharing of crash tool