Test language
Choose your default language for general test instructions. Questions will remain in English regardless of the language chosen.
Test duration: 70 mins
No. of questions: 2 questions
Choose language: EnglishCode Question 1
In managing tasks at an analytics platform, the goal is to efficiently schedule both primary and secondary tasks within specified time constraints.
There are n
primary tasks and n
secondary tasks. Two arrays, primary
and secondary
, provide information on task hours, where primary[i]
represents the duration in hours of the i-th primary task, and secondary[i]
represents the duration in hours of the i-th secondary task.
Each day on the platform has a time limit denoted as limit
hours. One primary task must be scheduled each day. If time remains after the primary task, you can choose to schedule at most one secondary task on that day. It is essential to ensure that the total hours do not exceed the specified limit.
Determine the maximum number of secondary tasks that can be scheduled during these n
days while adhering to the given constraints.
Example:
limit = 7
primary = [4, 5, 2, 4]
secondary = [5, 6, 3, 4]
One of the optimal scheduling can be:
- Day 1: Schedule the first primary task and the third secondary task. Total time is 4 + 3 = 7.
- Day 2: Schedule the second primary task. Total time is 5.
- Day 3: Schedule the third primary task and the first secondary task. Total time is 2 + 5 = 7.
- Day 4: Schedule the fourth primary task. Total time is 4.
There is no other arrangement of secondary tasks for which more than 2 secondary tasks can be scheduled in 4 days.
Therefore, the maximum number of secondary tasks that can be scheduled during these 4 days is 2.
Function Description
Complete the function getMaximumTasks
in the editor below.
getMaximumTasks
has the following parameters:
int limit
: the daily time limit for primary tasks and secondary tasks.int primary[n]
: the duration of the primary tasks.int secondary[n]
: the duration of the secondary tasks.
Returns:
int
: the maximum number of secondary tasks that can be scheduled during thesen
days.
Constraints:
- 1 ≤ n, limit ≤ 200,000
- 1 ≤
primary[i]
,secondary[i]
≤limit
Code Question 2
Within the Amazon Gaming Distribution System, a logistics coordinator is faced with the task of efficiently distributing a collection of n
computer games among k
different children. Each game is characterized by its size, denoted by gameSize[i]
for i
from 1 to n
.
To facilitate the distribution process, the coordinator opts to utilize pen drives, ordering k
pen drives with identical storage capacities. Each child can receive a maximum of 2 games, and every child must receive at least one game. Also, no game should be left unassigned.
Considering the impracticality of transferring large game files over the internet, the strategy involves determining the minimum storage capacity required for the pen drives. A pen drive can only store games if the sum of their sizes does not exceed the pen drive's storage capacity.
What is the minimum storage capacity of pen drives that you must order to be able to give these games to the children?
Example:
makefile复制代码n = 4
gameSize = [9, 2, 4, 6]
k = 3
We note that we will need pen drives of the size of at least 9 units, to store the first game.
This also turns out to be the minimum size of pen drives that should be ordered to give the games to these children.
We can use the first pen drive to store the game of size 9, the second one to store the second and third games, and the third pen drive to store the fourth game.
Hence, the minimum capacity of pen drives required is 9.
我们长期稳定承接各大科技公司如TikTok、Google、Amazon等的OA笔试代写服务,确保满分通过。如有需求,请随时联系我们。
We consistently provide professional online assessment services for major tech companies like TikTok, Google, and Amazon, guaranteeing perfect scores. Feel free to contact us if you're interested.