Print the Elements of a Linked List HackerRank Solution


Print the Elements of a Linked List HackerRank Solution
Source : https://www.hackerrank.com/challenges/print-the-elements-of-a-linked-list



Source : https://www.hackerrank.com/challenges/print-the-elements-of-a-linked-list


Solution


// Karthikalapati.blogspot.com
/*
Print elements of a linked list on console
Node is defined as
class Node {
int data;
Node next;
}
*/
void Print(Node head) {
Node n = head;
while (n != null) {
System.out.println(n.data);
n = n.next;
}
}

No comments:

Post a Comment