#C6701. Two Sum Exists
Two Sum Exists
Two Sum Exists
Given an array of integers and a target integer, determine whether there exist two distinct elements in the array whose sum is equal to the target value.
You are required to implement a solution that reads from standard input and writes to standard output. The input will include an array and a target value. Your task is to check if there is a pair of different elements in the array that add up to the target.
The approach should be efficient enough to handle large inputs. Use appropriate data structures where necessary.
In mathematical terms, given an array \(A = [a_1, a_2, \dots, a_n]\) and an integer \(T\), you need to determine if there exist two indices \(i, j\) with \(i \neq j\) such that \(a_i + a_j = T\).
inputFormat
The input is provided via standard input (stdin). The first line contains two integers (n) and (target), where (n) is the number of elements in the array and (target) is the target sum. The second line contains (n) space-separated integers representing the array.
outputFormat
Output a single line to standard output (stdout): "true" if there exists a pair of distinct elements that sum to the target value, otherwise "false".## sample
4 9
2 7 11 15
true