Print the Elements of a Linked List

Sort by

recency

|

857 Discussions

|

  • + 0 comments

    There is a problem to use recursion in this problem?

  • + 0 comments

    Here is my c++ solution:

    void printLinkedList(SinglyLinkedListNode* head) {
        for ( ; head != NULL; head = head->next)
        {
            cout << head->data << endl;
        }
    }
    
  • + 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;
        }
    }
    
  • + 0 comments

    What do you think about my iterative Java solution? 😀

    Video: https://www.youtube.com/watch?v=98QHX9FrITI

    Time complexity:
    Space complexity:

  • + 1 comment

    Swift template code is broken. (compile error)