链表题为什么不容易写对? 反转链表、合并有序链表这类简单题,在面试中能写对的人寥寥。
被指针的 next 绕晕,next.next 等
for (cur.next && cur.next.next) {
first := cur.next;
second := cur.next.next;
first.next = second.next;
cur.next = second;
cur.next.next = first;
cur = cur.next.next;
}
LeetBook:https://leetcode.cn/leetbook/detail/linked-list/