Why is is not passing all test cases?

@Ak07 conisder the cases where k = 0 or k >= n

Still only passing 3/6 test cases

@Ak07share the updated code