private static int minOperations ( int src , int target ) {
  Set < GFG > visited = new HashSet < > ( 1000 ) ;
  LinkedList < GFG > queue = new LinkedList < GFG > ( ) ;
  GFG node = new GFG ( src , 0 ) ;
  queue . offer ( node ) ;
  visited . add ( node ) ;
  while ( ! queue . isEmpty ( ) ) {
    GFG temp = queue . poll ( ) ;
    visited . add ( temp ) ;
    if ( temp . val == target ) {
      return temp . steps ;
    }
    int mul = temp . val * 2 ;
    int sub = temp . val - 1 ;
    if ( mul > 0 && mul < 1000 ) {
      GFG nodeMul = new GFG ( mul , temp . steps + 1 ) ;
      queue . offer ( nodeMul ) ;
    }
    if ( sub > 0 && sub < 1000 ) {
      GFG nodeSub = new GFG ( sub , temp . steps + 1 ) ;
      queue . offer ( nodeSub ) ;
    }
  }
  return - 1 ;
}

private static int minOperations ( int src , int target ) { Set < GFG > visited = new HashSet < > ( 1000 ) ; LinkedList < GFG > queue = new LinkedList < GFG > ( ) ; GFG node = new GFG ( src , 0 ) ; queue . offer ( node ) ; visited . add ( node ) ; while ( ! queue . isEmpty ( ) ) { GFG temp = queue . poll ( ) ; visited . add ( temp ) ; if ( temp . val == target ) { return temp . steps ; } int mul = temp . val * 2 ; int sub = temp . val - 1 ; if ( mul > 0 && mul < 1000 ) { GFG nodeMul = new GFG ( mul , temp . steps + 1 ) ; queue . offer ( nodeMul ) ; } if ( sub > 0 && sub < 1000 ) { GFG nodeSub = new GFG ( sub , temp . steps + 1 ) ; queue . offer ( nodeSub ) ; } } return - 1 ; }
(method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (generic_type (type_identifier) (type_arguments (type_identifier))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments)) arguments: (argument_list (decimal_integer_literal))))) (local_variable_declaration type: (generic_type (type_identifier) (type_arguments (type_identifier))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments (type_identifier))) arguments: (argument_list)))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (identifier) (decimal_integer_literal))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) (while_statement condition: (parenthesized_expression (unary_expression operand: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) (if_statement condition: (parenthesized_expression (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (identifier))) consequence: (block (return_statement (field_access object: (identifier) field: (identifier))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (decimal_integer_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (decimal_integer_literal)))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (binary_expression left: (identifier) right: (decimal_integer_literal)))) consequence: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (identifier) (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (decimal_integer_literal)))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (binary_expression left: (identifier) right: (decimal_integer_literal)))) consequence: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (identifier) (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (decimal_integer_literal)))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))))))) (return_statement (unary_expression operand: (decimal_integer_literal)))))