#C2731. Triplet Sum to Zero Problem
Triplet Sum to Zero Problem
Triplet Sum to Zero Problem
You are given an array of integers. Your task is to determine whether there exists a triplet (i.e. three elements) (a, b, c) in the array such that (a + b + c = 0). If such a triplet exists, output "YES"; otherwise, output "NO". Note that the array may contain duplicate elements.
inputFormat
The input is provided via standard input. The first line contains a single integer (n) (with (3 \leq n \leq 10^5)), representing the number of elements in the array. The second line contains (n) space-separated integers (a_1, a_2, \ldots, a_n) (where (-10^9 \leq a_i \leq 10^9)).
outputFormat
Print a single line to standard output containing "YES" if there exists a triplet (a, b, c) satisfying (a + b + c = 0), or "NO" if no such triplet exists.## sample
5
-1 2 9 -6 7
YES
</p>