Why it is showing run error

still pending no response

Hey @amansanyam,
You’re not checking the fact that if the k exceeds n, how will it handle those cases?
For k>=n , your code will throw error.