static void updateList ( Node head , int m ) {
  int cnt = cntNodes ( head ) ;
  if ( cnt != m && m < cnt ) {
    int skip = cnt - m ;
    Node prev = null ;
    Node curr = head ;
    while ( skip > 0 ) {
      prev = curr ;
      curr = curr . next ;
      skip -- ;
    }
    prev . next = null ;
    Node tempHead = head ;
    head = curr ;
    while ( curr . next != null ) curr = curr . next ;
    curr . next = tempHead ;
  }
  printList ( head ) ;
}

static void updateList ( Node head , int m ) { int cnt = cntNodes ( head ) ; if ( cnt != m && m < cnt ) { int skip = cnt - m ; Node prev = null ; Node curr = head ; while ( skip > 0 ) { prev = curr ; curr = curr . next ; skip -- ; } prev . next = null ; Node tempHead = head ; head = curr ; while ( curr . next != null ) curr = curr . next ; curr . next = tempHead ; } printList ( head ) ; }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation name: (identifier) arguments: (argument_list (identifier))))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (binary_expression left: (identifier) right: (identifier)))) consequence: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (identifier)))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (null_literal))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (identifier))) (while_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) body: (block (expression_statement (assignment_expression left: (identifier) right: (identifier))) (expression_statement (assignment_expression left: (identifier) right: (field_access object: (identifier) field: (identifier)))) (expression_statement (update_expression (identifier))))) (expression_statement (assignment_expression left: (field_access object: (identifier) field: (identifier)) right: (null_literal))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (identifier))) (expression_statement (assignment_expression left: (identifier) right: (identifier))) (while_statement condition: (parenthesized_expression (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (null_literal))) body: (expression_statement (assignment_expression left: (identifier) right: (field_access object: (identifier) field: (identifier))))) (expression_statement (assignment_expression left: (field_access object: (identifier) field: (identifier)) right: (identifier))))) (expression_statement (method_invocation name: (identifier) arguments: (argument_list (identifier))))))