Dsa
Math
Medium
Balanced Product Sequence
A sequence of positive integers is called balanced if the product of the first half equals the product of the second half. Given an array of integers, determine if it can be split into two balanced parts. If it can, print "YES", otherwise print "NO". The input starts with an integer N followed by N integers. For instance, if the input is "4 2 2 1 1", the output should be "YES" since (2*2) = (1*1).
Input Format:
- The first line contains an integer N (even, 2 <= N <= 100).
- The second line contains N space-separated integers.
Output Format:
- A single line: "YES" if the sequence can be split into two balanced products, otherwise "NO".
Example:
Input:
4
2 2 1 1
Output:
YES
Key concepts
mathproductssequence
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