Medium Accuracy: 56.22%
Submissions: 2348 Points: 4
Given an infinite number line. You start at 0 and can go either to the left or to the right. The condition is that in the ith move, youmust take i steps. Given a destination D , find the minimum number of steps required to reach that destination.
Input: D = 2
Explaination: The steps takn are +1, -2 and +3.
Input: D = 10
Explaination: The steps are +1, +2, +3 and +4.
You do not need to read input or print anything. Your task is to complete the function minSteps() which takes the value D as input parameter and returns the minimum number of steps required to reach the dedstination D from 0.
Expected Time Complexity: O(D) Expected Auxiliary Space: O(1)