kucheasysa

Algoverse_adesh_31

Jun 29th, 2024
504
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.43 KB | None | 0 0
  1. #User function Template for python3
  2.  
  3. '''
  4.  
  5. #Linked list class
  6. class LinkedList:
  7.    def __init__(self):
  8.        self.head=None
  9.        self.tail=None
  10.        '''
  11.  
  12.  
  13.  
  14. class Solution:
  15.    
  16.     #Function to count nodes of a linked list.
  17.     def getCount(self, head_node):
  18.         count=0
  19.         curr=head_node
  20.         while curr!=None:
  21.             count+=1
  22.             curr=curr.next
  23.         return count
  24.         #code here
  25.  
Advertisement
Add Comment
Please, Sign In to add comment