Challenge 1: Length of a Linked List

Find the length of the given linked list.

Problem Statement

Implement a function that takes a linked list testVariable and returns the length of the linked list.

Input

  1. A variable testVariable containing the linked list whose length will be calculated.
  2. The head node of the linked list head.

Output

Length of the input linked list

Sample Input

testVariable => 3 -> 4 -> 7 -> 11 -> None
head => 3

Sample Output

4

Try it Yourself

Try this challenge yourself before examining the solution. Good luck!

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.