Springworks Interview Question

Merge intervals of array problem