Skip to content

Latest commit

 

History

History
29 lines (18 loc) · 725 Bytes

File metadata and controls

29 lines (18 loc) · 725 Bytes

Singly Linked List Cycle Check

Problem

Given a singly linked list, write a function which takes in the first node in a singly linked list and returns a boolean indicating if the linked list contains a "cycle".

A cycle is when a node's next point actually points back to a previous node in the list. This is also sometimes known as a circularly linked list.

You've been given the Linked List Node class code:

class Node(object):

    def __init__(self,value):

        self.value = value
        self.nextnode = None

Leetcode: https://leetcode.com/problems/linked-list-cycle/

Code

Write your code in the form:

def cycle_check(node):
    pass #Your function should return a boolean