educative.io

Biased standing problem

I think loop should run from [1,n] instead of [1,n), otherwise it leaves the last element and will give the wrong answer.
Kindly let me know if my thought process is wrong

Hi @Priyam_Kumar

I also noticed the same thing. The loop should run [1,n] otherwise it will leave the last element unattended.

For that specific array, this mistake is not affecting the answer because “missing iteration” adds no value to “sum”
{for i=7, abs will return 0 and sum value will remain unchaged}
But for any other values, this thing will definitely affect the answer.