Please correct my code

@Lovishbansal hey when k>n then, we would not append n-1 , instead we will start circular counting, so effectively k = k%n.
If this resolves your doubt mark it as resolved.