Saturday, July 30, 2016

Find all unique pairs of element in an array that sum to S

Find all unique pairs of element in an array that sum to S

For ex. If array = {2,4,6,4,6} and S = 8 then answer is {<2,6>, <4,4>}

Input:
   values = { 2, 4, 6, 4, 4, 6, 5, 3 } and
   S = 8

Output:
    <5,3>   <4,4> <2,6>



No comments:

Post a Comment