#C5116. Two Sum Problem
Two Sum Problem
Two Sum Problem
Given a list of integers and a target sum, determine whether there exist two distinct numbers in the list such that their sum is equal to the target.
Formally, for an array \(A\), find two different indices \(i\) and \(j\) with \(i \neq j\) such that \(A_i + A_j = \text{target}\). This problem requires you to efficiently check for a valid pair using standard input and output for data communication.
inputFormat
The input is given in three lines:
- The first line contains an integer \(n\), representing the number of elements in the list.
- The second line contains \(n\) space-separated integers.
- The third line contains an integer \(target\), representing the target sum.
outputFormat
Output a single line containing either True
if there exists two distinct numbers in the list whose sum equals the target, or False
otherwise.
4
2 7 11 15
9
True