Question bank › Two Pointers
Dsa Two Pointers Medium

Balanced Swap

You are given an integer array 'nums' of even length 'n'. Your goal is to determine if it's possible to swap exactly one pair of numbers in 'nums' such that the sum of the first half equals the sum of the second half. If possible, output 'YES', otherwise output 'NO'. Input Format: - A single line containing 'n' followed by 'n' space-separated integers. Output Format: - A single line 'YES' or 'NO'. Example: Input: 6 1 2 3 4 5 6 Output: YES

Key concepts

two_pointersarray_manipulationgreedy

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.