THE PROBLEM :
MY SOLUTION :
The solution works, but unfortunately it is really too slow when k is large (k can b