text function hasCycle(head): if head == null: return false slow = head fast = head while fast != null and fast.next != null: slow = slow.next fast = fast.next.next if slow == fast: return true return false Time complexity: . Fast pointer will either reach the end or meet slow within steps. Space complexity: . Two pointers.
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
$ curl repovive.com/roadmaps/maang-interview-prep/linked-lists/linked-list-cycle-pseudocode
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░███████████████████████████████████████████████████████████████████████████████████████████