Solve question (1) with the condition that the integer k should never move more than one position in a single move anytime during the execution of the search. If you need to move k more than one step, it will count multiple moves. Here k is given as an additional last input.