<awangdev>Gray Code_1.java
public void helper(List<Integer> rst, char[] list, int index) {
        
        rst.add(Integer.parseInt(new String(list), 2));                
        
        list[index] = list[index] == '0' ? '1' : '0';
        int num = Integer.parseInt(new String(list), 2);
        if (!rst.contains(num)) {
            helper(rst, list, index);
        }
        list[index] = list[index] == '0' ? '1' : '0';
        
        if (index -1 >= 0) {
             list[index - 1] = list[index - 1] == '0' ? '1' : '0';
             num = Integer.parseInt(new String(list), 2);
             if (!rst.contains(num)) {
                 helper(rst, list, index - 1);
             }
            list[index - 1] = list[index - 1] == '0' ? '1' : '0';
        }
        
        if (index + 1 < list.length) {
             list[index + 1] = list[index + 1] == '0' ? '1' : '0';
             num = Integer.parseInt(new String(list), 2);
             if (!rst.contains(num)) {
                 helper(rst, list, index + 1);
             }
            list[index + 1] = list[index + 1] == '0' ? '1' : '0';
        }
    }
public void sample_funcname ( List < Integer > rst , char [ ] list , int index ) {
  rst . add ( Integer . parseInt ( new String ( list ) , 2 ) ) ;
  list [ index ] = list [ index ] == '0' ? '1' : '0' ;
  int num = Integer . parseInt ( new String ( list ) , 2 ) ;
  if ( ! rst . contains ( num ) ) {
    helper ( rst , list , index ) ;
  }
  list [ index ] = list [ index ] == '0' ? '1' : '0' ;
  if ( index - 1 >= 0 ) {
    list [ index - 1 ] = list [ index - 1 ] == '0' ? '1' : '0' ;
    num = Integer . parseInt ( new String ( list ) , 2 ) ;
    if ( ! rst . contains ( num ) ) {
      helper ( rst , list , index - 1 ) ;
    }
    list [ index - 1 ] = list [ index - 1 ] == '0' ? '1' : '0' ;
  }
  if ( index + 1 < list . length ) {
    list [ index + 1 ] = list [ index + 1 ] == '0' ? '1' : '0' ;
    num = Integer . parseInt ( new String ( list ) , 2 ) ;
    if ( ! rst . contains ( num ) ) {
      helper ( rst , list , index + 1 ) ;
    }
    list [ index + 1 ] = list [ index + 1 ] == '0' ? '1' : '0' ;
  }
}
