Author: Mahmoud Badawy
Tester: Mohammed Ehab
You have a array which has two ones and other elements are zeros you can find the sum of elements in the interval [l,r] find where the two elements are
use binary search to find them
You can use binary search to find them by dividing the array to two pieces and search in the piece which has two criminals until you reach a point which have a criminal in its right and the other in its left you will then do a normal binary search
iterate over all places to find the place of the criminals
Binary Search solution can be found here.
iterative solution can be found here.