FastPrepMaximum Total Length of Non-Overlapping Intervals
Problems/Maximum Total Length of Non-Overlapping Intervals

Maximum Total Length of Non-Overlapping Intervals

Bloomberg LP logoBloomberg LP● MediumNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report describes a Bloomberg new-grad virtual-onsite problem. You return a list of non-overlapping intervals with the largest total length, and the report says it is not the same as Meeting Rooms. In our version, an interval includes its start but not its end, so touching ends are fine. There is exactly one best answer, and the output comes in a fixed order.

Given an array of half-open intervals [start, end), choose a pairwise non-overlapping subset whose total covered length is maximum. Two intervals are compatible when one interval's end is less than or equal to the other's start.

Return the chosen intervals sorted by increasing start, breaking ties by increasing end. The input is guaranteed to have a unique maximum-total-length subset.

Function

maximumLengthIntervals(intervals: int[][]) → int[][]

Examples

Example 1

intervals = [[1,4],[3,6],[5,10],[6,8]]return = [[1,4],[5,10]]

The two returned intervals do not overlap and have total length 3 + 5 = 8, which is maximal.

Example 2

intervals = [[0,10],[1,4],[4,8]]return = [[0,10]]

The long interval contributes length 10, exceeding the compatible pair's total length of 7.

Example 3

intervals = [[1,3],[3,7],[2,6]]return = [[1,3],[3,7]]

Touching half-open intervals are compatible, so the first two provide total length 6.

Constraints

  • 1 <= intervals.length <= 10000
  • intervals[i].length == 2
  • 0 <= intervals[i][0] < intervals[i][1] <= 1000000000
  • The maximum-total-length compatible subset is unique.

More Bloomberg LP Onsite Interview questions

  • Collatz Conjecture with Shared MemoizationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Top K Frequent WordsONSITE INTERVIEW · Seen Nov 2026
  • Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Add Two Numbers IIPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Decode StringPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Minimum Replacements to Make Two Strings AnagramsPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026

Similar questions at other companies

  • Russian Doll EnvelopesGoogle · ONSITE INTERVIEWGoogle interview questions
  • Russian Doll EnvelopesInMobi · ONSITE INTERVIEWInMobi interview questions
  • Russian Doll EnvelopesAirbnb · ONSITE INTERVIEWAirbnb interview questions
  • Fill a Time Window with SongsMicrosoft · OAMicrosoft interview questions
  • Maximum Taxi EarningsWells Fargo · OAWells Fargo interview questions
  • Maximum Profit in Job SchedulingAmazon · PHONE SCREEN
  • 3Sum SmallerSalesforce · ONSITE INTERVIEWSalesforce interview questions
  • Minimum Removals for a Nice ArrayAdobe · ONSITE INTERVIEWAdobe interview questions
  • Longest Increasing SubsequenceExpedia · ONSITE INTERVIEWExpedia interview questions
  • Minimum Cost for TicketsRoku · ONSITE INTERVIEWRoku interview questions

Bloomberg LP interview experiences

  • Bloomberg AI-Assisted Coding Round, All Levels: 14 Experiences
  • Bloomberg SWE Intern Interview Questions: 68 Questions
  • Bloomberg Interview Questions, Level Not Reported: 65 Questions
  • Bloomberg Experienced Design & More: 126 Questions (Part 2 of 2)
  • Bloomberg Experienced SWE Interviews: 167 Questions (Part 1 of 2)
  • Bloomberg New Grad Coding Questions: 121 Questions (Part 2 of 2)
All Bloomberg LP interview questionsSee Bloomberg LP hiring insights
Saved
class Solution {
    public int[][] maximumLengthIntervals(int[][] intervals) {
        // Write your code here.
    }

}
Checking account…