186. Zero-Sum Subarray Exists?
EasyPrefix SumHash Set
Print YES if some non-empty contiguous subarray sums to zero, else NO.
Input format
Line 1: n Line 2: n integers
Output format
YES or NO
Example 1
Input
5 4 2 -3 1 6
Output
YES
Example 2
Input
3 4 2 0
Output
YES
Constraints
1 ≤ n ≤ 10⁵
Read input from standard input and print the answer to standard output. Your code is judged against 6 test cases, most of them hidden.
Loading the MyLoginn IDE…