Linked List, Easy
Question
Given a linked list, determine if it has a cycle in it.
Follow up:
Can you solve it without using extra space?
Answer
HashSet
|
|
Running time: O(n)
Fast and Slow pointer
|
|
Running time: O(n)
Anne.github.io
Given a linked list, determine if it has a cycle in it.
Follow up:
Can you solve it without using extra space?
HashSet
|
|
Running time: O(n)
Fast and Slow pointer
|
|
Running time: O(n)