Java solution with my experience


#1

public class Solution {
public int solve(int A) {
int target = Math.abs(A);
if(target==0) return 0;
int sum = 0, steps = 0;
while(sum<target)
{
sum+=steps;
steps++;
}

    while((sum-target)%2==1){
        sum+=steps;
        steps++;
    }
    return steps-1;
}

}

Just reduce the time by removing the negative side of line and considering just the positive side. Its all right if u didn’t get it by yourself i also got the solution after understanding the concept

IF U DIDN’T GET FROM CODE PLEASE CHECK THE GIVEN VIDEO QUESTION IS NOT THAT EASY BUT ONCE YOU UNDERSTAND THE CONCEPT ITS DONE!!! ALL THE BEST