#C10591. Pair With Target Sum

    ID: 39813 Type: Default 1000ms 256MiB

Pair With Target Sum

Pair With Target Sum

Given an array of integers and a target value, determine whether there exist two distinct elements in the array such that their sum equals the target. Formally, you are to decide if there exist indices (i) and (j) with (i \neq j) satisfying $$a_i + a_j = \text{target}.$$

This is a common problem in competitive programming that tests your ability to use efficient data structures to achieve the desired time complexity.

inputFormat

The first line of input contains two integers (n) and (target), where (n) denotes the number of elements in the array. The second line contains (n) space-separated integers representing the array elements.

outputFormat

Print a single line containing the string 'YES' if there exist two distinct elements whose sum equals (target), otherwise print 'NO'.## sample

6 9
1 3 4 6 7 8
YES