Hoarding programming problems for you!

Looking for good programming challenges?

Use the search below to find our solutions for selected questions!

Sum of 2 numbers in an array

Sharing is caring!

Problem statement
Identify whether there exists a pair of numbers in an array such that their sum is equal to N.

Input
The first line contains one integer N, which is the sum we are trying to find. The second line contains one integer M, which is the length of the array. This is followed by M lines each containing one element of the array.

Output
Output 1 if there exists a pair of numbers in the array such that their sum equals N. If such a pair does not exist, output 0.

Sample Input

Sample Output

Solution