Count nodes in Circular linked list

Sairam Penjarla
Oct 30, 2020

Given a circular linked list, count number of nodes in it

def get_length(self):
temp =self.head
count = 0
if temp == None:
return count
while(temp):
count +=1
temp = temp.next
if temp==self.head:
return count

--

--

Sairam Penjarla

Looking for my next opportunity to make change in a BIG way