Need help with this query problem !
Difference between en2 and en3, changed 24 character(s)
Given a binary string S of 0s and 1s of length N and M queries of the type [l, r],↵
find the number of substrings of S(l to r) where there are even 1s.↵

Constraints:↵

N <= 10^5↵

M <= 10^5↵

1 <= l <= r <= N↵

Sample Input:↵

N = 5↵

S = 10001↵

M = 2↵

2 4↵

3 5↵


Sample Output:↵

6↵

3↵

Explanation:↵

For [2, 4] the 6 valid substrings are [2,2], [2,3], [2,4], [3,3], [3,4], [4,4]↵

For [3, 5] the 3 valid substrings are [3,3], [3,4], [4,4] 

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English ritik0602 2021-09-16 12:17:39 24
en2 English ritik0602 2021-09-16 12:15:43 2 Tiny change: '], [4,4]\nFor [3, ' -> '], [4,4]\n\nFor [3, '
en1 English ritik0602 2021-09-16 12:09:24 474 Initial revision (published)