#K51832. Two Sum Problem
Two Sum Problem
Two Sum Problem
You are given a list of n integers and a target integer T. Your task is to find two distinct indices i and j (0-indexed) such that:
\(a_i + a_j = T\)
If there are multiple solutions, return the first valid pair encountered. If no such pair exists, output None
.
inputFormat
The input is read from standard input (stdin) and consists of three lines:
- The first line contains an integer n denoting the number of elements in the list.
- The second line contains n space-separated integers.
- The third line contains an integer T denoting the target sum.
outputFormat
If a valid pair is found, output two space-separated integers denoting their 0-indexed positions. Otherwise, output None
.
4
2 7 11 15
9
0 1