Facebook | Min Time to Execute Tasks

Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2015-10-29Added By Anonymous
Source: Link

Company: Meta
Role: unknown
Interview Stage: unknown
Location: unknown
Year: unknown

Original Post Content:

Given a set of tasks, and int k, which is the waiting time between two same tasks. Calculate the min total execution time if you are allowed to rearrange the tasks. Assume the execution for each individual task is 1.

Example:
Input: tasks = [A A B], k = 1
Output: 3
Explanation:
Without rearrangement, the execution time would be 4:

A wait A B

1 1 1 1

With rearrangement, the execution time would be 3:

A B A

1 1 1

Related problems:
https://leetcode.com/problems/rearrange-string-k-distance-apart (premium)

Comments