#C5800. Pair Sum Detection

    ID: 49490 Type: Default 1000ms 256MiB

Pair Sum Detection

Pair Sum Detection

Given an array of integers and an integer target (T), determine if there exists two distinct indices (i) and (j) such that (a_i + a_j = T). In other words, check whether there exists a pair of different numbers in the array whose sum equals the target. This problem tests your ability to perform efficient lookups using data structures like hash sets.

inputFormat

The input is given via standard input (stdin) with 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 (T), the target sum.

Note: When (n = 0), the second line will be empty.

outputFormat

Print to standard output (stdout) a single line containing either "true" or "false" (without quotes). Print "true" if there exists a pair of distinct numbers in the array that sum to (T); otherwise, print "false".## sample

5
3 4 7 1 12
10
true