Company: cashfree_29oct
Difficulty: medium
Minimum Moves to Exact Target Problem Description You stand at position 0 on an infinite number line and want to land exactly on a given position target . The moves are numbered 1, 2, 3, ... . On move number i you must travel exactly i units, and you choose the direction: either +i or -i . You may not skip a move, shorten it or lengthen it. Return the smallest number of moves after which your position is exactly target . Function Description Complete the reachTarget function. It takes the following parameter: target : INTEGER, the position to land on. The function must return an INTEGER, the minimum number of moves. Input Format A single line containing the integer target . Output Format Print a single integer: the minimum number of moves. Constraints 0 <= target <= 1000000000 Examples Example 1 Input: 7 Output: 5 Explanation: +1, +2, +3, -4, +5 lands on 1 + 2 + 3 - 4 + 5 = 7 . No sequence of four or fewer moves reaches 7. Example 2 Input: 3 Output: 2 Explanation: +1, +2 reaches