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
|
834 Discussions
|
Please Login in order to post a comment
Traverse the list untill you get null as the next address.
if(head!= null){ while(head!= null){ Console.WriteLine(head.data); head = head.next; } }
C++ (more at https://github.com/IhorVodko/Hackerrank_solutions/tree/master , feel free to give a star :) )
def printLinkedList(head): cur = head while cur is not None: print(cur.data) cur = cur.next
void printLinkedList(SinglyLinkedListNode* head) { SinglyLinkedListNode *temp = head; while(temp!= NULL){ cout<data<next;
}