算法面试——链表进阶:环形链表、复制随机指针链表
一、环形链表(判断有环)
public boolean hasCycle(ListNode head) {ListNode slow head, fast head;while (fast ! null && fast.next ! null) {slow slow.next;fast fast.next.next;if (slow fast) return true;}return false;
}二、环形链…
2026/8/6 4:25:46