...
/Challenge: Inserting Elements in a Linked List
Challenge: Inserting Elements in a Linked List
Test your knowledge by solving this coding challenge.
We'll cover the following...
We'll cover the following...
Introduction
To practice working with linked lists, you’ll have to implement the following functions:
listLength, which returns the number of elements inside a linked list.insertAtPos, which inserts an element at a specified position inside a list.
The listLength function
Problem statement
Write a function listLength, which takes a list as input and returns the number of elements inside the list.
For example:
- For the list
[1, 2, 3, 4, 5], return5, which is the number of elements. - For the empty list
[], return