#K70747. Find the Contiguous Subarray with a Given Sum

    ID: 33377 Type: Default 1000ms 256MiB

Find the Contiguous Subarray with a Given Sum

Find the Contiguous Subarray with a Given Sum

Given an array of integers and a target integer \(T\), determine whether there exists a contiguous subarray (i.e., a sequence of consecutive elements) whose sum equals \(T\). If such a subarray exists, output the starting and ending indices (0-indexed) of the subarray; otherwise, output None.

Note that if the input array is empty, the answer is always None. This problem tests your ability to use efficient data structures, such as hash maps, to solve problems involving subarray sums.

inputFormat

The input is read from standard input (stdin) and consists of three parts:

  1. An integer \(N\) representing the number of elements in the array.
  2. A line with \(N\) space-separated integers representing the array.
  3. An integer \(T\) representing the target sum.

outputFormat

Output to standard output (stdout) the starting and ending indices (0-indexed) of a contiguous subarray whose sum equals \(T\), separated by a space. If no such subarray exists, output None.

## sample
5
1 2 3 7 5
12
1 3