Google | Phone Interview | June
Anonymous User
1844

You are given with an array of inifinite size. In some of the intervals of indexes, this array contains 1. You can only scan through K number of consecutive array elements and you need to count much 1's you can go through in a single scan.

for example :-

intervals = [[0,2], [4,9], [10, 12]], K = 7. (Here, Ending index is not included).

Then in this, if you start scan from 4 till 11(which is 4+K), you can through 6, 1's at max.

What is the optimal approach to solve this problem

Comments (6)