Company: cashfree_29oct
Difficulty: medium
Minimum Moves to Exact Target Problem Description Given a target position on a one-dimensional number line, find the minimum number of moves required to land exactly on the target position, starting from 0. In the i th move (1-based), you can take exactly i steps forward or backward. Examples Example 1: Input: target = 7 Output: 5 Explanation: A possible sequence of moves to reach the target is as follows: Move 1: Take 1 step forward. Position = 0 + 1 = 1. Move 2: Take 2 steps forward. Position = 1 + 2 = 3. Move 3: Take 3 steps forward. Position = 3 + 3 = 6. Move 4: Take 4 steps backward. Position = 6 - 4 = 2. Move 5: Take 5 steps forward. Position = 2 + 5 = 7. After 5 moves, the position is exactly 7. The answer cannot be better than the given number of moves. Hence, the answer is 5. Example 2: Input: target = 3 Output: 2 Explanation: A possible sequence of moves to reach the target is as follows: Move 1: Take 1 step forward. Position = 0 + 1 = 1. Move 2: Take 2 steps forward. Positio