Solve interval merging and histogram area
ByteDanceSoftware Engineer · Technical ScreenLast updated
This question evaluates algorithmic problem-solving skills focused on interval manipulation and histogram-based area computation, emphasizing data structures, ordering, and reasoning about time and space complexity.
The coding round included two algorithm problems:
-
Merge overlapping intervals: Given a list of closed intervals
[[start1, end1], [start2, end2], ...], merge all overlapping intervals and return a new list of non-overlapping intervals sorted by start time. -
Maximum rectangle in a histogram: Given an array of non-negative integers where each value represents the height of a histogram bar of width
1, return the maximum rectangular area that can be formed using one or more consecutive bars.
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.