Can you tell me the error?

hello @vageesha

u missed the case where k is greater than n
check now->