Find all pairs with sum equals to " sum - arr [ i ] "
HashSet < int > s = new HashSet < int > ( ) ; for ( int j = i + 1 ; j < n ; j ++ ) { int x = sum - ( arr [ i ] + arr [ j ] ) ; if ( s . Contains ( x ) ) Console . Write ( " { 0 } ▁ { 1 } ▁ { 2 } STRNEWLINE " , x , arr [ i ] , arr [ j ] ) ; else s . Add ( arr [ j ] ) ; } } }