#C5010. Taco: Two Sum Problem
Taco: Two Sum Problem
Taco: Two Sum Problem
You are given an array of integers and a target integer \(T\). Your task is to determine whether there exist two distinct elements in the array such that their sum is equal to \(T\). If such a pair is found, output their 0-based indices (with the pair corresponding to the first valid occurrence). Otherwise, output None
.
Note: If multiple valid pairs exist, you may output any one of them. Your solution is expected to run in linear time on average.
inputFormat
The input is provided via standard input (stdin) and follows this format:
- The first line contains an integer \(n\), representing the number of elements in the array.
- The second line contains \(n\) space-separated integers, representing the array elements.
- The third line contains a single integer \(T\), the target sum.
outputFormat
Output to standard output (stdout) a single line containing two space-separated integers that are the indices of the two numbers that add up to \(T\). If no such pair exists, output None
.
4
2 7 11 15
9
0 1