#K39522. Two Sum Problem

    ID: 26439 Type: Default 1000ms 256MiB

Two Sum Problem

Two Sum Problem

You are given a list of integers and a target integer \(T\). Your task is to determine whether there exists a pair of distinct integers in the list that add up to \(T\). This problem tests your ability to use efficient data structures for quick lookup (e.g., a hash set) to achieve an optimal solution.

Example: For the list [2, 7, 11, 15] and target 9, the output is True because \(2 + 7 = 9\).

You should read the input from standard input and write the output to standard output.

inputFormat

The first line contains an integer (n) which is the number of elements in the list. The second line contains (n) space-separated integers. The third line contains an integer (T), the target sum.

outputFormat

Output True if there exists a pair of distinct integers that add up to (T), otherwise output False.## sample

4
2 7 11 15
9
True