#K52877. Two Sum Pair Existence

    ID: 29407 Type: Default 1000ms 256MiB

Two Sum Pair Existence

Two Sum Pair Existence

You are given an array of integers and an integer k. Your task is to determine whether there exist two distinct indices i and j such that the sum of the elements at these indices equals k. In other words, check if there exist i and j (i ≠ j) for which:

$a_i + a_j = k$

This problem tests the ability to efficiently search for a pair of numbers in an array that satisfy the sum condition. Use appropriate data structures (for example, hashing) to achieve the optimal solution.

inputFormat

The input is given via standard input and has the following format:

  • The first line contains two integers n and k where n is the size of the array and k is the target sum.
  • The second line contains n space-separated integers denoting the elements of the array.

outputFormat

Output a single line to standard output with the answer: print YES if there exists a pair of distinct elements whose sum equals k, otherwise print NO.

## sample
5 9
2 7 11 15 3
YES