#K83767. Two Sum Problem
Two Sum Problem
Two Sum Problem
Given an array of integers and an integer \( k \), determine whether there exist two distinct elements in the array whose sum equals \( k \). If such a pair exists, output True
; otherwise, output False
.
The solution should efficiently check for the existence of a pair \( a \) and \( b \) such that \( a + b = k \) using appropriate data structures.
inputFormat
The input is read from stdin and has the following format:
- The first line contains an integer \( n \) representing the number of elements in the array.
- The second line contains \( n \) space-separated integers.
- The third line contains an integer \( k \).
outputFormat
Output to stdout a single line: True
if there exists a pair of numbers in the array that add up to \( k \), otherwise output False
.
4
10 15 3 7
17
True