[Go] Linked List - Summary - Two-Pointer in Linked List from Java to Go
Code Java // Initialize slow & fast pointers ListNode slow = head; ListNode fast = head; /** * Change this condition to fit specific problem. * Attention: remember to avoid null-pointer error **/ while (slow != null && fast != null && fast.next != null) { slow = slow.next; // move slow pointer one step each time fast = fast.next.next; // move fast pointer two steps each time if (slow == fast) { ..
Go/Leet Code
2022. 5. 1. 23:24