AGNIKUL COSMOS | On-Campus OA (2023) | Find the Pivot Integer
Question · Posted Jun 2026
Problem Statement Given a positive integer n, find a pivot integer x such that: 1 + 2 + ... + x = x + (x + 1) + ... + n Return the pivot integer if it exists; otherwise return -1. Example Input n = 8 Output 6 Explanation 1 + 2 + 3 + 4 + 5 + 6 = 21 6 + 7 + 8 = 21 Therefore, the pivot integer is: 6 Constraints 1 <= n <= ...
The full answer & interview discussion are available to premium members.
Log in Create a free account