I am not able to generalize this :
f(x,k) = A(x+n-1)%n+1+A(x+n-2)%n+1+…+A(x+n-k)%n+1.
and this…f(l,r)+f(l+1,r)…
I am not able to generalize this
f(x,k) = A(x+n-1)%n+1+A(x+n-2)%n+1+…+A(x+n-k)%n+1.
Look closely, this is actually continuous elements of an array starting from x-1 to x-k. HOW?
(A + B) mod C = (A mod C + B mod C) mod C
which is a basic property of modulo
f(l,r)+f(l+1,r)
replace x in the above relation by l, l+1, so on
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.