Print the Elements of a Linked List

Sort by

recency

|

864 Discussions

|

  • + 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

  • + 0 comments

    Here is my c++ solution, you can watch the explanation here : https://youtu.be/t3gCqS1F24w

    void printLinkedList(SinglyLinkedListNode* head) {
    
        while(head != nullptr){
            cout << head -> data << endl;
            head = head -> next;
        }
    }