#C14863. Two Sum Problem
Two Sum Problem
Two Sum Problem
You are given an array of integers and a target integer. Your task is to find two distinct indices i and j (0-indexed) such that
[ a_i + a_j = target ]
If such a pair exists, output the two indices; otherwise, output None
. It is guaranteed that each input has at most one solution.
inputFormat
The input is given via standard input in the following format:
- Line 1: An integer n, representing the number of elements in the array.
- Line 2: n space-separated integers representing the array elements.
- Line 3: An integer representing the target sum.
outputFormat
If a valid pair is found, output two integers (the indices) separated by a space. If no such pair exists, output None
.
4
2 7 11 15
9
0 1