static Node reverse ( Node head , int k ) {
  Node prev = null ;
  Node curr = head ;
  Node temp = null ;
  Node tail = null ;
  Node newHead = null ;
  Node join = null ;
  int t = 0 ;
  while ( curr != null ) {
    t = k ;
    join = curr ;
    prev = null ;
    while ( curr != null && t -- != 0 ) {
      temp = curr . next ;
      curr . next = prev ;
      prev = curr ;
      curr = temp ;
    }
    if ( ( newHead == null ) ) newHead = prev ;
    if ( tail != null ) tail . next = prev ;
    tail = join ;
  }
  return newHead ;
}

static Node reverse ( Node head , int k ) { Node prev = null ; Node curr = head ; Node temp = null ; Node tail = null ; Node newHead = null ; Node join = null ; int t = 0 ; while ( curr != null ) { t = k ; join = curr ; prev = null ; while ( curr != null && t -- != 0 ) { temp = curr . next ; curr . next = prev ; prev = curr ; curr = temp ; } if ( ( newHead == null ) ) newHead = prev ; if ( tail != null ) tail . next = prev ; tail = join ; } return newHead ; }
(method_declaration (modifiers) type: (type_identifier) 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: (type_identifier) declarator: (variable_declarator name: (identifier) value: (null_literal))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (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: (null_literal))) (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: (null_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (while_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (null_literal))) body: (block (expression_statement (assignment_expression left: (identifier) right: (identifier))) (expression_statement (assignment_expression left: (identifier) right: (identifier))) (expression_statement (assignment_expression left: (identifier) right: (null_literal))) (while_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (null_literal)) right: (binary_expression left: (update_expression (identifier)) right: (decimal_integer_literal)))) body: (block (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 (assignment_expression left: (identifier) right: (identifier))) (expression_statement (assignment_expression left: (identifier) right: (identifier))))) (if_statement condition: (parenthesized_expression (parenthesized_expression (binary_expression left: (identifier) right: (null_literal)))) consequence: (expression_statement (assignment_expression left: (identifier) right: (identifier)))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (null_literal))) consequence: (expression_statement (assignment_expression left: (field_access object: (identifier) field: (identifier)) right: (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (identifier))))) (return_statement (identifier))))