Tap here to switch tabs
Problem
Submissions

Problem: Find the Pivot Integer

med
30 min
Try to solve the Find the Pivot Integer problem.

Statement

Given a positive integer n, find the pivot integer x such that the sum of all integers from 11 to x inclusive is equal to the sum of all integers from x to n inclusive.

Return the integer x. If no such integer exists, return −1-1. It is guaranteed that there is at most one pivot integer for any valid input.

Constraints:

  • 1≤1 \leq n ≤1000\leq 1000

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Find the Pivot Integer

med
30 min
Try to solve the Find the Pivot Integer problem.

Statement

Given a positive integer n, find the pivot integer x such that the sum of all integers from 11 to x inclusive is equal to the sum of all integers from x to n inclusive.

Return the integer x. If no such integer exists, return −1-1. It is guaranteed that there is at most one pivot integer for any valid input.

Constraints:

  • 1≤1 \leq n ≤1000\leq 1000