Company: goldman sachs

Difficulty: medium

Problem Statement

Maximum Distinct Color Overlap You are given `N` inclusive intervals on an integer number line. Each interval is written as `color start end`, where `color` is `0` (Red), `1` (Green), or `2` (Blue), and `start <= end`. A color can occur in several intervals. At any coordinate, a color counts once if at least one interval of that color contains the coordinate. Find the maximum number of distinct colors present at the same coordinate. Input Format The first line contains an integer `N`. Each of the next `N` lines contains three integers: `color start end`. Output Format Print one integer: the maximum number of distinct colors present simultaneously. Constraints - `1 <= N <= 200000` - `0 <= color <= 2` - `-10^9 <= start <= end <= 10^9` Notes Intervals are inclusive. If multiple intervals of the same color overlap, that color still contributes only one to the answer. Example Input `3\n0 1 5\n1 4 8\n2 4 4` Output `3` At coordinate `4`, Red, Green, and Blue are all pr

More goldman sachs OA questionsInterview experiences