evenCost
and oddCost
, to store the total moves required for even and odd indices respectively.i
.i
, determine the minimum value of the adjacent elements (if they exist).evenCost
if i
is even, or to oddCost
if i
is odd.evenCost
and oddCost
.