Counting the Nodes
Iterative and recursive way of counting the number of nodes in a linked list.
Iterative Method :
Recursive Method :
Time and Space Complexity :
Time complexity : O(n) Space complexity : O(1)
Contributed by Nitin Ranganath
Last updated