FastPrepMerge Intervals by Type
Problems/Merge Intervals by Type

Merge Intervals by Type

Bloomberg LP logoBloomberg LP● MediumNEW GRADPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report describes a variation of Merge Intervals where every interval has a type, and a hash table keeps the merging separate for each type. We spell out that the input comes as parallel lists, that intervals include both ends, and the order of the output. Our version is about 65% the same as the reported question.

Given types and intervals, merge overlapping intervals that have the same type and return the merged intervals.

At index i, intervals[i] is a closed interval [start, end] of type types[i]. A closed interval includes both endpoints.

Group intervals by their types. Within each type, sort by increasing start, then by increasing end. Merge the next interval into the current one when its start is at most the current end.

Return each merged interval as [type, start, end]. Write the endpoints as decimal strings.

List type groups in the order they first appear in types. Within each group, list intervals by increasing start.

Function

mergeIntervalsByType(types: String[], intervals: int[][]) → String[][]

Examples

Example 1

types = ["A","B","A","A","B"]intervals = [[1,4],[2,3],[3,7],[10,12],[3,8]]return = [["A","1","7"],["A","10","12"],["B","2","8"]]

The overlapping A intervals form [1,7], while the later A interval stays separate. The B intervals share endpoint 3, so they also merge.

Example 2

types = ["X","Y","X"]intervals = [[5,5],[1,2],[1,3]]return = [["X","1","3"],["X","5","5"],["Y","1","2"]]

X appears first in types, so its intervals are listed before Y's. X's intervals are ordered by start, even though its later interval appeared first in the input.

Example 3

types = []intervals = []return = []

Both arrays are empty, so there are no intervals to merge and the result is empty.

Constraints

  • 0 <= types.length == intervals.length <= 100000.
  • Each type is a nonempty alphanumeric string of length at most 20.
  • Every interval has exactly two endpoints.
  • 0 <= start <= end <= 1000000000.
  • The total output size is at most the input size.

More Bloomberg LP Phone Screen questions

  • Pascal's TrianglePHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
  • Valid Triangle NumberPHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
  • 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
  • Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Fewest Coins CombinationPHONE SCREEN · Seen Nov 2026
  • Recommend Films from Viewers Who Watched Everything You DidPHONE SCREEN · Seen Nov 2026
  • Track New Values in Sorted OrderPHONE SCREEN · Seen Nov 2026
  • Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026

Similar questions at other companies

  • Top K Frequent ElementsAmazon · OA · PHONE SCREEN · ONSITE INTERVIEW
  • Mutual-Friend RecommendationsMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
  • Filter, Sort, and Deduplicate Scheduled TasksRippling · PHONE SCREEN · ONSITE INTERVIEWRippling interview questions
  • Longest Consecutive SequenceJP Morgan Chase · PHONE SCREENJP Morgan Chase interview questions
  • Top K Frequent Elements with a Recency TiebreakSwiggy · PHONE SCREEN
  • Pins Violation Log QueriesPinterest · PHONE SCREENPinterest interview questions
  • Group AnagramsWorkday · PHONE SCREEN
  • Build a Task and Subtask HierarchyStripe · PHONE SCREENStripe interview questions
  • Find All Points Within a RadiusGoogle · PHONE SCREENGoogle interview questions
  • Resource Reconciler: Plan and Apply CreatesPerplexity AI · PHONE SCREENPerplexity AI interview questions

Interview reports that mention this question

  • Bloomberg New Grad SWE Interviews: 98 Experiences (Part 1 of 5)

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)
All Bloomberg LP interview questionsSee Bloomberg LP hiring insights
Saved
class Solution {
    public String[][] mergeIntervalsByType(String[] types, int[][] intervals) {
        // Write your code here.
    }

}
Checking account…