static void checkAllOnes ( int arr [ ] , int n , int k ) {
  int brr [ ] = new int [ n ] ;
  for ( int i = 0 ;
  i < n ;
  i ++ ) {
    if ( arr [ i ] == 1 ) {
      int h = k + 1 ;
      int j = i ;
      while ( ( j >= 0 ) && ( h -- != 0 ) ) {
        brr [ j ] = 1 ;
        j -- ;
      }
      h = k + 1 ;
      j = i ;
      while ( ( j < n ) && ( h -- != 0 ) ) {
        brr [ j ] = 1 ;
        j ++ ;
      }
    }
  }
  int flag = 0 ;
  for ( int i = 0 ;
  i < n ;
  i ++ ) {
    if ( brr [ i ] == 0 ) {
      flag = 1 ;
      break ;
    }
  }
  if ( flag == 1 ) System . out . println ( "0" ) ;
  else System . out . println ( "1" ) ;
}

static void checkAllOnes ( int arr [ ] , int n , int k ) { int brr [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] == 1 ) { int h = k + 1 ; int j = i ; while ( ( j >= 0 ) && ( h -- != 0 ) ) { brr [ j ] = 1 ; j -- ; } h = k + 1 ; j = i ; while ( ( j < n ) && ( h -- != 0 ) ) { brr [ j ] = 1 ; j ++ ; } } } int flag = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( brr [ i ] == 0 ) { flag = 1 ; break ; } } if ( flag == 1 ) System . out . println ( "0" ) ; else System . out . println ( "1" ) ; }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier) dimensions: (dimensions)) (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (identifier))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))) consequence: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (decimal_integer_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) (while_statement condition: (parenthesized_expression (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (parenthesized_expression (binary_expression left: (update_expression (identifier)) right: (decimal_integer_literal))))) body: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))) (expression_statement (update_expression (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal)))) (expression_statement (assignment_expression left: (identifier) right: (identifier))) (while_statement condition: (parenthesized_expression (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (parenthesized_expression (binary_expression left: (update_expression (identifier)) right: (decimal_integer_literal))))) body: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))) (expression_statement (update_expression (identifier))))))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal))) (break_statement))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal)))) alternative: (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal)))))))