n
using the formula totalSum = n * (n + 1) / 2
.leftSum
to 0 to keep track of the running sum.n
:
a. Add the current number to leftSum
.
b. If totalSum - leftSum + current number
equals leftSum
, return the current number as the pivot integer.