We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Print the Elements of a Linked List
Print the Elements of a Linked List
Sort by
recency
|
866 Discussions
|
Please Login in order to post a comment
Just like layers of river rocks stack up beneath the earth over time, each node in a linked list connects to the next solid, grounded, and part of a bigger structure.
Here's a solution in C#
Python
Java 8 SinglyLinkedListNode current = head; while (current != null) { System.out.println(current.data); current = current.next; }
Why my code is not working? Javascript mode. In google debbuger is printing each element.
function print (head){ if(head.length == null){ return null } else { for(let i = 0; i < head.length; i++){ console.log(head[i]) } } }