Please check my code and tell me why all test cases are not passed.
Something is wrong in my code
it is mentioned in the question that the k can be greater then the n so you have to handle that case as well.
you can handle that by doing taking modulus.