You are viewing a single comment's thread. Return to all comments →
This is a good reason to start looping on the first element of the input, rather than the output.
But the problem statement does say you are "Given an array" (not a stream).
Nah I did not add anything except changed the gived codes from a [a_i] = in.nextInt() to a[((n- (k%n))+a_i)%n] = in.nextInt()
can you pl explain a[((n- (k%n))+a_i)%n] = in.nextInt() st