<gouthampradhan>bit_manipulation_BinaryNumberWithAlternatingBits_1.java
public boolean hasAlternatingBits(int n) {
    int curr = n & 1;
    int pos = 0;
    for (int i = 0; i < 32; i++) {
      if ((n & (1 << i)) > 0) {
        pos = i;
      }
    }
    for (int i = 1; i <= pos; i++) {
      int temp = (1 << i) & n;
      if ((temp > 0 && curr > 0) || (temp == 0 && curr == 0)) return false;
      curr = temp;
    }
    return true;
  }
public boolean var_0 ( int var_1 ) {
  int var_3 = var_1 & 1 ;
  int var_5 = 0 ;
  for ( int var_6 = 0 ;
  var_6 < 32 ;
  var_6 ++ ) {
    if ( ( var_1 & ( 1 << var_6 ) ) > 0 ) {
      var_5 = var_6 ;
    }
  }
  for ( int var_6 = 1 ;
  var_6 <= var_5 ;
  var_6 ++ ) {
    int var_8 = ( 1 << var_6 ) & var_1 ;
    if ( ( var_8 > 0 && var_3 > 0 ) || ( var_8 == 0 && var_3 == 0 ) ) return false ;
    var_3 = var_8 ;
  }
  return true ;
}
