<awangdev>717. 1-bit and 2-bit Characters_2.java
public boolean isOneBitCharacter(int[] bits) {
        if (bits == null || bits.length == 0) {
            return false;
        }
        int n = bits.length;
        if (n == 1) {
            return bits[0] == 0;
        }
        if (bits[n - 1] != 0) {
            return false;
        }
        
        boolean[] dp = new boolean[n];
        dp[0] = bits[0] == 0;
        dp[1] = bits[0] != 0 || bits[1] != 1;
        for (int i = 2; i < n - 1; i++) {
            if (bits[i] == 0) {
                dp[i] = dp[i - 2] || dp[i - 1];
            } else if (bits[i] == 1) {
                dp[i] = dp[i - 2] && bits[i - 1] == 1;
            }
        }
        return dp[n - 2];
    }
public boolean var_0 ( int [ ] var_1 ) {
  if ( var_1 == null || var_1 . length == 0 ) {
    return false ;
  }
  int var_5 = var_1 . length ;
  if ( var_5 == 1 ) {
    return var_1 [ 0 ] == 0 ;
  }
  if ( var_1 [ var_5 - 1 ] != 0 ) {
    return false ;
  }
  boolean [ ] var_8 = new boolean [ var_5 ] ;
  var_8 [ 0 ] = var_1 [ 0 ] == 0 ;
  var_8 [ 1 ] = var_1 [ 0 ] != 0 || var_1 [ 1 ] != 1 ;
  for ( int var_10 = 2 ;
  var_10 < var_5 - 1 ;
  var_10 ++ ) {
    if ( var_1 [ var_10 ] == 0 ) {
      var_8 [ var_10 ] = var_8 [ var_10 - 2 ] || var_8 [ var_10 - 1 ] ;
    }
    else if ( var_1 [ var_10 ] == 1 ) {
      var_8 [ var_10 ] = var_8 [ var_10 - 2 ] && var_1 [ var_10 - 1 ] == 1 ;
    }
  }
  return var_8 [ var_5 - 2 ] ;
}
