Cyclic Detection
Start Timer
0:00:00
Given a ListNode
representing the head of a linked list, write a function is_cyclic
which returns True
if a linked list is cyclic and False
if it is not. A linked list is cyclic when there is no tail to the linked list, and the supposed tail is attached to another node inside the list itself, creating a cycle.
A ListNode
is defined as:
class ListNode:
value: ListNode = None
next: ListNode = None
Example:
Input:
Output:
def is_cyclic(head) -> True
Recommended questions for you
Personalized based on your user activity, skill level, and preferences.
.
.
.
.
.
.
.
.
.
Comments