Maximum difference of adjacent elements of remaining array
int maxDiff = int . MinValue ; for ( int j = 0 ; j < temp . Count - 1 ; j ++ ) { maxDiff = Math . Max ( maxDiff , temp [ j + 1 ] - temp [ j ] ) ; } minDiff = Math . Min ( minDiff , maxDiff ) ; } } return minDiff ; } static int countSetBits ( int x ) { int setBits = 0 ; while ( x != 0 ) { x = x & ( x - 1 ) ; setBits ++ ; } return setBits ; }