...

/

Solution Review: Is Circular Linked List

Solution Review: Is Circular Linked List

This lesson contains the solution review for the challenge of determining whether a given linked list is circular or not.

We'll cover the following...

In this lesson, we investigate how to determine whether a given linked list is either a singly linked list or a circular linked list.

Implementation

Have a look at the coding solution below:

Press + to interact
def is_circular_linked_list(self, input_list):
if input_list.head:
cur = input_list.head
while cur.next:
cur = cur.next
if cur.next == input_list.head:
return True
return False
else:
return False

Explanation

Let’s discuss the class method is_circular_linked_list. First, we check whether or not parameter is empty. ...