For two set bits , two of the three variable i , j , k will be equal and the third will not be . Set both the bits where two variabls are equal and the bit which is not equal , and add it to the set
else if ( i == j && j != k ) { long toAdd = ( 1L << i ) + ( 1L << k ) ; allNum . add ( toAdd ) ; } else if ( i == k && k != j ) { long toAdd = ( 1L << i ) + ( 1L << j ) ; allNum . add ( toAdd ) ; } else if ( j == k && k != i ) { long toAdd = ( 1L << j ) + ( 1L << i ) ; allNum . add ( toAdd ) ; }