Solved LeetCode program · 535 of 1,000
#0754 · Reach a Number
Original English source
The target is 3. The distance is the absolute value of target. The total is 0. The steps is 0.
Repeat while total is less than distance.
Add 1 to steps. Add steps to total.
Repeat while (total minus distance) modulo 2 is not 0.
Add 1 to steps. Add steps to total.
Show steps.
Expected stdout
2