[TikTok] E-commerce Recommendation Infrastructure

Showtime Scheduling

TikTok is hosting a virtual talent show organized by a group of influencers, showcasing a variety of engaging performances.

Each performance is scheduled with a specific startTime when the performer takes the stage and an endTime by which the act must conclude to keep the audience engaged.

However, each performer can only showcase one act at a time. With multiple performances potentially overlapping, the organizers need to determine the minimum number of performers required to ensure that all acts are featured without any conflicts.

Formally, given a schedule of n performances, where the i-th performance starts at startTime[i] and ends at endTime[i] minutes (both inclusive). Find the minimum number of performers required to ensure that all acts are completed without any overlapping assignments for each performer.

Note: If a performer completes an act at time x minutes, they can only take on acts that begin at x + 1 minutes or later.


Example

n = 3
startTime = [1, 4, 5]
endTime = [3, 5, 6]

If there is only one performer, notice that the second act starts at 4 minutes and ends at 5 minutes, while the third act begins right at 5 minutes. Since both acts require a performer at the 5-minute mark, they overlap, meaning at least one additional performer is needed.

With two performers, the first performer performs the first act from 1 to 3 minutes, the second performer takes over for the second act from 4 to 5 minutes, and the first performer returns to perform the third act from 5 to 6 minutes.

Therefore, the minimum number of performers required to complete all the acts without any overlaps is 2.


Function Description

Complete the function getMinPerformers in the editor below.

getMinPerformers takes the following arguments:

  • int startTime[n]: an array of integers representing the start times of each performance.
  • int endTime[n]: an array of integers representing the end times of each performance.

Returns
int: the minimum number of performers required to complete all the acts.


Constraints

  • 1 ≤ n ≤ 10^5
  • 1 ≤ startTime[i], endTime[i] ≤ 10^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.

Leave a Reply

Your email address will not be published. Required fields are marked *