algorithm-linked-list
链表相关
翻转链表
12345678910ListNode reverseList(ListNode head) { ListNode pre = null, cur = head; while (cur != null) { ListNode next = cur.next; cur.next = pre; pre = cur; cur = next; } return pre;}
快慢指针找中间节点
12345678ListNode getMidNode(ListNode head) { ListNode fast = head, slow = head; while (fast != null && fast.next != null) { slow = slow.next; fast = fast.next.next; } return slow;} ...