Hackerank mathematics

For this kind of range query sums ,which apprach to use mo’s algorithm or segment trees or anything else.

This problem can be solved using map, what you have to do is that
There are 3 conditions that needs to be checked in the following order.

  1. If A[a] is odd, irrespective of what A[b] is, the answer is odd .
  2. If a == b, then the answer is even ( as the condition #1 is executed in case the number is odd).
  3. If A[a+1] == 0, then the answer is odd as x0 = 1.

If none of the above conditions match, return even .

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.