Skip to content

Latest commit

 

History

History
22 lines (16 loc) · 416 Bytes

Find the Pivot Integer.md

File metadata and controls

22 lines (16 loc) · 416 Bytes
int pivotInteger(int n) {

        int sum = 0;

        for(int i=1;i<=n;i++)
            sum += i;

        int t = 0;
        for(int i=0;i<=n;i++)
        {
             t +=i;
            if(t == sum-t+i)
                return i;
        }
        return -1;
    }