#C440. Subarray Sum (Contiguous)

    ID: 47934 Type: Default 1000ms 256MiB

Subarray Sum (Contiguous)

Subarray Sum (Contiguous)

You are given an array of integers and an integer target. Your task is to determine whether there exists a contiguous subarray whose sum is exactly equal to the target.

In other words, you need to find indices i and j such that

$$ \sum_{k=i}^{j} a_k = target $$

If such a subarray exists, print True; otherwise, print False.

Note: The array may contain negative numbers, zeros, or positive numbers. Ensure that your solution is efficient enough to handle the input within reasonable constraints.

inputFormat

The input is read from standard input (stdin) and has the following format:

  • The first line contains an integer n — the number of elements in the array.
  • The second line contains n space-separated integers representing the elements of the array.
  • The third line contains a single integer target — the target sum.

outputFormat

Output a single line to standard output (stdout) with either True if a contiguous subarray with sum equal to target exists, or False otherwise.

## sample
6
1 4 20 3 10 5
33
True