At first find the cumulative sum of the given array. After that for each query find the sum of the given range using the help of cumulative sum. This sum will give us the number ones in the given range,let it be O. Now for the last part to determine the count of zero, let Len=(R-L)+1 which is the length of the query. Now let Z=Len-O. Finally, we now know the value of Z and O, all that's left to check is Z>O, if it is 0 wins otherwise 1.

Statistics

73% Solution Ratio
steinumEarliest, Oct '20
Kuddus.6068Fastest, 0.0s
tarek007Lightest, 524 kB
Being_GoromShortest, 307B
Toph uses cookies. By continuing you agree to our Cookie Policy.