FastPrepTask Scheduler with Cooldown
Problems/Task Scheduler with Cooldown

Task Scheduler with Cooldown

SambaNova Systems logoSambaNova Systems● MediumNEW GRADPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A firsthand SambaNova new-grad phone report dated June 3, 2022 describes a list of tasks and a cooling time before the same task can run again. It asks for the final finish time, as a math exercise. Our version is about 94% the same as the reported question.

Each task takes one time unit. You may execute tasks in any order or remain idle, but two executions of the same task ID must have at least cooldown intervening time units.

Return the minimum total number of time units needed to execute every task.

Function

leastInterval(tasks: String[], cooldown: int) → int

Examples

Example 1

tasks = ["A","A","A","B","B","B"]cooldown = 2return = 8

A B idle A B idle A B is optimal.

Example 2

tasks = ["A","A","A","B","B","B"]cooldown = 0return = 6

No cooldown requires no idle time.

Example 3

tasks = ["A","A","A","B","B","B","C","C"]cooldown = 2return = 8

C tasks fill both idle positions.

Constraints

  • 1 <= tasks.length <= 100000.
  • Task IDs are non-empty uppercase ASCII strings of at most 20 characters.
  • 0 <= cooldown <= 100000.

More SambaNova Systems Onsite Interview questions

  • Vectorized K-Means AssignmentsONSITE INTERVIEW · Seen Apr 2024
  • 4Sum II Tuple CountONSITE INTERVIEW · Seen Jun 2022
  • Bomb Enemy Best CoordinatesONSITE INTERVIEW · Seen Jun 2022
  • Sum Nodes with an Even-Valued GrandparentONSITE INTERVIEW · Seen Jun 2022
  • Validate Binary Search TreeONSITE INTERVIEW · Seen Jun 2022
  • Deterministic Zigzag SortPHONE SCREEN · ONSITE INTERVIEW · Seen Jun 2022
  • Maximum Area of IslandONSITE INTERVIEW · Seen Jun 2022
  • Point Inside a TrianglePHONE SCREEN · ONSITE INTERVIEW · Seen Jun 2022
  • Parse Variable, Expression, and Application TreesPHONE SCREEN · ONSITE INTERVIEW · Seen Mar 2022
  • Flip Equivalent Binary TreesONSITE INTERVIEW · Seen Oct 2021

Similar questions at other companies

  • Task Scheduler with CooldownTeradata · PHONE SCREEN
  • Task Scheduler with CooldownGoogle · ONSITE INTERVIEWGoogle interview questions
  • Nickname-Constrained GroupingZoox · ONSITE INTERVIEW
  • Partition Into K-Size Consecutive GroupsDream11 · ONSITE INTERVIEWDream11 interview questions
  • Future-Aware Cache EvictionBenchling · PHONE SCREENBenchling interview questions
  • Minimum Baskets with Distinct Fruit TypesAmazon · ONSITE INTERVIEW
  • Minimum Rounds to Complete All TasksInfosys · OAInfosys interview questions
  • Minimum Distinct Prefix CostChubb · OAChubb interview questions
  • Minimum Distinct Prefix CostGoldman Sachs · OAGoldman Sachs interview questions
  • Rearrange Songs by AuthorZomato / Eternal · OAZomato / Eternal interview questions
All SambaNova Systems interview questionsSee SambaNova Systems hiring insights
Saved
class Solution {
    public int leastInterval(String[] tasks, int cooldown) {
        // write your code here
    }
}
Checking account…