Fanatics Interview Question

variation of overlapping problem and one array question medium