Given an array of 1’s and 0’s and a set of ranges, find out the number of 0’s in each range (i, j) including both indexes.// Input Array: [1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1] size n
// Range Array: [[0,4], [3,6], [1, 5], [0, 7]] size m
// Output: [3, 3, 4, 6]FollowUp:
For the same input find out the number of 0’s which are guarded by 1’s on left and right within the same range.
// Output: [2, 0, 0, 2]I was able to solve the first part in O(n) but not the follow up.
Any help is appreciated for the follow up.