Getting wrong answer in 2 testcases

what would happen if k>n , please explain

@aryanv instead of passing k to the function, pass (k%n). In this way, if k is smaller than n then value of k will be passed, and if k is larger than n, then value of (k%n) will be passed, which is smaller than the value of k, and you will also get the correct answer.
Hope this helps.

1 Like