#K59747. Pair Sum Finder

    ID: 30933 Type: Default 1000ms 256MiB

Pair Sum Finder

Pair Sum Finder

You are given an array of integers and a target integer k. Your task is to determine whether there exists a pair of distinct indices \(i\) and \(j\) in the array such that \(a_i + a_j = k\). This problem tests your ability to efficiently search for pairs using appropriate data structures.

Note: The indices must be distinct. For example, even if a number appears twice in the array, they can form a valid pair if their sum equals k.

inputFormat

The input is read from standard input (stdin) and has the following format:

  1. The first line contains an integer (n), the number of elements in the array.
  2. The second line contains (n) space-separated integers representing the array.
  3. The third line contains an integer (k), the target sum.

For example:

5 2 7 11 15 1 9

outputFormat

Output to standard output (stdout) a single line containing "yes" if there exists at least one pair of distinct indices (i) and (j) such that (a_i + a_j = k). Otherwise, output "no".## sample

5
2 7 11 15 1
9
yes