n are written in a row. Find a number x from that row such that the sum of all numbers from 1 to x equals the sum of all numbers from x to n (x itself counts in both sums).
Return x, or -1 if there is no such number. When x exists, it is unique.n=49 → 35
1 + 2 + … + 35 = 630 and 35 + 36 + … + 49 = 630.
n=5 → -1
No x from 1 to 5 works: for example, x = 4 gives 10 on the left and 9 on the right.
n=1 → 1
n=49
35
Run checks the first 3 tests in your browser. Submit checks all 55 tests on the server, hidden ones included.