educative.io

Educative

Should we merge intersections?

Should the solution merge the intersections?

Interval[] input1 = new Interval[] { new Interval(1, 4), new Interval(5, 6), new Interval(7, 9) };
Interval[] input2 = new Interval[] { new Interval(2, 3), new Interval(4, 7) };

// produces
Intervals Intersection: [2,3] [4,4] [5,6] [7,7] 

// with merged intersections
Intervals Intersection: [2-7]