• + 0 comments

    I agree that it could've been explicit, but the first alternative I got was using a check if the index wasn't within the array bounds and continue the loop if that was the case. It solved the error I was getting from trying to access a non-existent array in my arr, but if If did it that way, one query simply wasn't being processed, resulting in the wrong output.

    The modulo of n gave this wrapping effect that gave me the expected output.