Showing posts with label find pair. Show all posts
Showing posts with label find pair. Show all posts

write a c program that given a set a of n numbers and another number x determines whether or not there exist two elements in s whose sum is exactly x



Given an array A[] and a number x, check for pair in A[] with sum as x

Write a C program that, given an array A[] of n numbers and another number x, determines whether or not there exist two elements in S whose sum is exactly x.
There can be several ways to do, what we found are two methods.
1 ) Using Sort input Array                                           2) Using Hash Map