#C14411. Zero Sum Subarray

    ID: 44058 Type: Default 1000ms 256MiB

Zero Sum Subarray

Zero Sum Subarray

Given an array of integers and an integer k, determine whether there exists a contiguous subarray of length at least k whose sum equals zero.

A subarray is defined as a contiguous portion of the array.

Constraints:

  • $$1 \le n \le 1000$$, where n is the number of elements in the array.
  • $$-10^4 \le nums[i] \le 10^4$$ for each element nums[i].
  • $$1 \le k \le n$$

Example:

Input:
7
1 2 -3 4 -2 -2 5
3

Output: True

</p>

inputFormat

The input is read from stdin and consists of three lines:

  1. The first line contains a single integer n, the number of elements in the array.
  2. The second line contains n space-separated integers representing the array elements.
  3. The third line contains a single integer k.

outputFormat

Print to stdout a single line containing either True if there exists a contiguous subarray of length at least k that sums to zero, or False otherwise.

## sample
7
1 2 -3 4 -2 -2 5
3
True