Problem · Intervals

Merge Intervals with Names

Learn this problem
MediumGoogle logoGoogleONSITE INTERVIEW
See Google hiring insights

Problem statement

This is like merge interval question but the result needs to have a list of names in the interval too. The OP mentioned that they did not quite sure how the list of names is done...And neither am I..😱

Function

mergeIntervalsWithNames(intervals: String[][]) → String[]

Examples

Example 1

intervals = [["Foo", "10", "30"], ["Bar", "15", "45"]]return = ["10 15 Foo", "15 30 Foo, Bar", "30 45 Bar"]
🐠

Constraints

🐳

More Google problems

drafts saved locally
public String[] mergeIntervalsWithNames(String[][] intervals) {
  // write your code here
}
intervals[["Foo", "10", "30"], ["Bar", "15", "45"]]
expected["10 15 Foo", "15 30 Foo", "Bar", "30 45 Bar"]
checking account