FastPrepTask Scheduling
Problems/Task Scheduling

Task Scheduling

JP Morgan Chase logoJP Morgan Chase● MediumINTERNOA

Updated Oct 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: 🐨 Corrected on 2026-07-18. The previous version transposed values between the second sample's arrays, creating an invalid task with a start time greater than its end time. This version restores the source arrays: start = [2, 1, 5, 5, 8] and end = [5, 3, 8, 6, 12]. The judged core task otherwise matches the visible source at about 99%.

Special thanks: 🌷 A special thank you to our lovely, amazing frenz who shared that this question appeared again on October 4, 2026! ദ്ദി ˉ͈̀꒳ˉ͈́ )✧ 💜

Given a set of n tasks, the task at index i, where 0 ≤ i < n, runs from time start[i] through end[i]. Find the minimum number of machines required to complete the tasks. A task can be scheduled on exactly one machine, and one machine can run only one task at a time.

Function

getMinMachines(start: int[], end: int[]) → int

Examples

Example 1

start = [1, 8, 3, 9, 6]end = [7, 9, 6, 14, 7]return = 3

Consider the following task schedule. Times in parentheses are the inclusive start and end times for each job.

  • Machine 1: [(1, 7), (8, 9)]
  • Machine 2: [(3, 6), (9, 14)]
  • Machine 3: [(6, 7)]

Here, the number of machines required is 3.

Example 2

start = [2, 1, 5, 5, 8]end = [5, 3, 8, 6, 12]return = 3
  • Machine 1: [(2, 5), (8, 12)]
  • Machine 2: [(1, 3), (5, 8)]
  • Machine 3: [(5, 6)]

At time 5, three tasks are active because task endpoints are inclusive, so three machines are necessary and sufficient.

Example 3

start = [2, 2, 2, 2]end = [5, 5, 5, 5]return = 4
  • Machine 1: [(2, 5)]
  • Machine 2: [(2, 5)]
  • Machine 3: [(2, 5)]
  • Machine 4: [(2, 5)]

Constraints

  • 1 ≤ n ≤ 2 * 105
  • 1 ≤ start[i] ≤ end[i] ≤ 109

More JP Morgan Chase interview questions

  • Longest Consecutive SequencePHONE SCREEN · Seen Nov 2026
  • LFU CacheONSITE INTERVIEW · Seen Nov 2026
  • LRU CacheONSITE INTERVIEW · Seen Nov 2026
  • Find Total CostOA · Seen Oct 2026
  • Minimum Meeting RoomsOA · Seen Oct 2026
  • Count Dropped RequestsOA · Seen Oct 2026
  • Maximize Binary XOR with a Set-Bit LimitPHONE SCREEN · Seen Oct 2026
  • Maximize Minimum Deployment DifficultyOA · Seen Oct 2026
  • Substring RemovalOA · Seen Oct 2026
  • Maximum Game Board ScoreOA · Seen Sep 2026

Similar questions at other companies

  • Maximum Number of Events That Can Be AttendedSnowflake · PHONE SCREENSnowflake interview questions
  • Minimum Workers with Job AssignmentsLyft · ONSITE INTERVIEWLyft interview questions
  • Minimum Meeting RoomsSentry · PHONE SCREENSentry interview questions
  • Minimum Cars for Rental RequestsGoogle · OA · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
  • Maximize Revenue from Decreasing InventoryChubb · OAChubb interview questions
  • Maximum Compatible Time WindowsIBM · OAIBM interview questions
  • Package Delivery SystemAmazon · OA
  • Rearrange Songs by AuthorZomato / Eternal · OAZomato / Eternal interview questions
  • Minimum Markers to Clear Line SegmentsHSBC · OAHSBC interview questions
  • Process SchedulerGoldman Sachs · OAGoldman Sachs interview questions

JP Morgan Chase interview experiences

  • JPMorgan Chase Experienced SWE Java Interview: 1 Experience
  • JPMorgan Quant Stats Superdays: 3 Experiences (Part 3 of 3)
  • JPMorgan Quant Modeling Superdays: 7 Experiences (Part 2 of 3)
  • JPMorgan Quant Intern Superday: 19 Experiences (Part 1 of 3)
  • JP Morgan Chase Data and AI Intern Superday: 11 Experiences
  • JPMorgan Code for Good India 2024: 6 Experiences (Part 5 of 5)
All JP Morgan Chase interview questionsSee JP Morgan Chase hiring insights
Saved
class Solution {
    public int getMinMachines(int[] start, int[] end) {
      // write your code here
    }

}
Checking account…