Challenge 1: Length of a Linked List
Find the length of the given linked list.
We'll cover the following
Problem Statement
Implement a function that takes a linked list testVariable
and returns the length of the linked list.
Write your code in the space provided in the file
index.js
.
Input
- A variable
testVariable
containing the linked list whose length will be calculated. - The head node of the linked list
head
.
Output
Length of the input linked list
Sample Input
testVariable => 4 -> 3 -> 11 -> 7 -> null
head => 4
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 80+ hands-on prep courses.