#K50102. Find the Special Element
Find the Special Element
Find the Special Element
Given an integer T representing the number of test cases, and for each test case an array of n integers, determine if there exists a special element in the array.
An element is considered special if it meets the following conditions:
- It appears exactly once in the array.
- If we denote the sum of all elements to the left of this element by \(S_L\) and the sum of all elements to the right by \(S_R\), then the element is special if \(S_L = S_R\).
For each test case, output YES
if a special element exists; otherwise, output NO
.
inputFormat
The first line of the input contains an integer T, the number of test cases.
For each test case:
- The first line contains an integer n, the number of elements in the array.
- The second line contains n space-separated integers representing the array.
outputFormat
For each test case, output a single line with YES
if there exists a special element; otherwise, output NO
.
3
5
1 2 3 2 1
4
1 2 3 4
6
1 2 3 4 3 2
YES
NO
NO
</p>