File: root - text - article - 2020 - 02 - multitasking.txt
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 1196 Views, 25124 Search Bots | 77 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 1196 Views, 25124 Search Bots | 77 Words
| Browse | Archive
Hi, here's your problem today. This problem was recently asked by AirBNB:
We have a list of tasks to perform, with a cooldown period. We can do multiple of these at the same time, but we cannot run the same task simultaneously.
Given a list of tasks, find how long it will take to complete the tasks in the order they are input.
tasks = [1, 1, 2, 1]
cooldown = 2
output: 7 (order is 1 _ _ 1 2 _ 1)
def findTime(arr, cooldown):
# Fill this in.
print findTime([1, 1, 2, 1], 2)
# 7
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Cateogry: Computing | 1196 Views, 25124 Search Bots | 77 Words We have a list of tasks to perform, with a cooldown period. We can do multiple of these at the same time, but we cannot run the same task simultaneously.
Given a list of tasks, find how long it will take to complete the tasks in the order they are input.
tasks = [1, 1, 2, 1]
cooldown = 2
output: 7 (order is 1 _ _ 1 2 _ 1)
def findTime(arr, cooldown):
# Fill this in.
print findTime([1, 1, 2, 1], 2)
# 7
Related Articles
- Daily Interview Problem: Reverse Words in a String
- Daily Interview Problem: Distribute Bonuses
- [Daily Problem] Validate Balanced Parentheses
- Daily Interview Puzzle: Intersection of Linked Lists
- Daily Interview Problem: Trapping Rainwater
- [Daily Problem] Add two numbers as a linked list
- Daily Interview Problem: Maximum Profit From Stocks
- Daily Interview Problem: Word Ordering in a Different Alphabetical Order
- Daily Interview Problem: Longest Substring With K Distinct Characters
- Daily Interview Problem: Largest Product of 3 Elements I
©2006~2024 SteakOverCooked - 0.00728 Seconds(s) - 2498.311 KB/s - 27 Online Memory: 491.51 KB
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - Server PHP Version: 7.4.33
How to Cook a Perfect Steak? | <meta name="robots" content="noindex, follow" />
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - Server PHP Version: 7.4.33
Comments (0)
Read & Write - Normal - Mini - Post - All Comments - Statistics
Be the first one to comment this page !