Print the Elements of a Linked List

Sort by

recency

|

865 Discussions

|

  • + 0 comments

    Here's a solution in C#

    static void printLinkedList(SinglyLinkedListNode head) {
            while(head != null){
                Console.WriteLine(head.data);
                head = head.next;
            }
        }
    
  • + 0 comments

    Python

    def printLinkedList(head):
        while head:
            print(head.data)
            head=head.next
    
  • + 0 comments

    Java 8 SinglyLinkedListNode current = head; while (current != null) { System.out.println(current.data); current = current.next; }

  • + 0 comments

    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]) } } }

  • + 0 comments

    Great challenge for beginners! Just like optimizing code for readability, tools like CapCut make video editing simple and clean—perfect for sharing coding tutorials or walkthroughs