FastPrepMinimum Preparation Time for Two Handlers
Problems/Minimum Preparation Time for Two Handlers

Minimum Preparation Time for Two Handlers

Amazon logoAmazon● MediumFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

You are given a work queue workList. Two handlers share the jobs, and the jobs must be done in the order they appear. Each value in workList is a work type from 1 through m.

Each job goes to exactly one of the two handlers. Before a handler does a job of type t, it pays a preparation time:

  • If the handler's previous job was the same type, it pays shortPrepTime[t].
  • Otherwise it pays longPrepTime[t]. This covers the first time the handler does that type and any job that comes right after a different type.

Return the minimum total preparation time.

Write minPreparationTime, which gets three arguments:

  1. int[] workList: the ordered work types
  2. int[] longPrepTime: long preparation time for each work type
  3. int[] shortPrepTime: short preparation time for each work type

minPreparationTime returns an int: the minimum total preparation time.

Function

minPreparationTime(workList: int[], longPrepTime: int[], shortPrepTime: int[]) → int

Examples

Example 1

workList = [1, 2, 2]longPrepTime = [4, 5]shortPrepTime = [2, 3]return = 12

Assign work type 1 to the first handler, then assign both type-2 jobs to the second handler. The total cost is 4 + 5 + 3 = 12.

Example 2

workList = [1, 1, 1]longPrepTime = [4]shortPrepTime = [2]return = 8

Use the same handler for all three jobs. Its first job pays the long time, and the next two jobs pay the short time. The total is eight.

Constraints

  • workList[i] is a work type between 1 and m
  • longPrepTime and shortPrepTime contain one entry per work type.
  • Jobs must be processed in order.

More Amazon Online Assessment questions

  • Maximize K-Element AND with an Increment BudgetOA · Seen Nov 2026
  • Task SchedulerOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Top K Frequent ElementsOA · PHONE SCREEN · Seen Nov 2026
  • Get Smallest Base SegmentOA · Seen Nov 2026
  • Minimum Cost of Left and Right PropagationOA · Seen Nov 2026
  • Minimum Grid InconvenienceOA · Seen Nov 2026
  • Maximize Shipment Order by Sorting One WindowOA · Seen Nov 2026
  • Maximum Equal-Bit Pairs in a SubsequenceOA · Seen Nov 2026
  • First Non-Repeating CharacterOA · ONSITE INTERVIEW · Seen Nov 2026
  • Two SumOA · PHONE SCREEN · Seen Nov 2026

Similar questions at other companies

  • Maximum Game Score with Fixed Forward JumpsStripe · OAStripe interview questions
  • 0/1 KnapsackConfluent · OAConfluent interview questions
  • Minimum Cost to Tile a Strip with Widths 1, 2, and 3Infosys · OAInfosys interview questions
  • Maximum Escape Game ScoreMicrosoft · OAMicrosoft interview questions
  • Maximum Subarray SumStraive · OA
  • Longest Increasing Price SubsequenceOpenAI · OAOpenAI interview questions
  • Lowest-Cost Shirt Color ScheduleElevenLabs · OAElevenLabs interview questions
  • Maximum Game Board ScoreJP Morgan Chase · OAJP Morgan Chase interview questions
  • API Bandwidth AllocationArista Networks · OAArista Networks interview questions
  • Maximum Points by Deleting ElementsIBM · OAIBM interview questions

Interview reports that mention this question

  • Amazon Full-Time OA Problems, Recent Reports (Part 4 of 5)

Amazon interview experiences

  • Amazon Experienced SDE Onsite Questions: 1 Experience
  • Amazon SDE Onsite Interview Questions: 9 Experiences
  • Amazon SDE II and L5 FDE Interview Questions: 4 Experiences
  • Amazon Full-Time OA Problems, Earlier Reports (Part 5 of 5)
  • Amazon New Grad OA Problems: Every Task We Have (Part 3 of 5)
See Amazon hiring insights
Saved
class Solution {
    public int minPreparationTime(int[] workList, int[] longPrepTime, int[] shortPrepTime) {
        // write your code here
    }

}
Checking account…