private ListNode reverse(ListNode head) {

    if (head == null) {
      return null;
    }

    ListNode prev = null;
    ListNode curt = head;
    ListNode next = curt.next;

    while (curt != null && next != null) {
      curt.next = prev;
      prev = curt;
      curt = next;
      next = curt.next;
    }
    curt.next = prev;
    return curt;
  }