Solving 'Print the Elements of a Linked List' from Hacker Rank ( Easy ) - Problem solving in JS

preview_player
Показать описание
Recursive solution:
function printLinkedList(head) {
if(!head) return;
}

I'm solving this problem in JS

* It's just a way for me to keep solving questions... *

My Profile :

Рекомендации по теме
Комментарии
Автор

Recursive solution =

function printLinkedList(head) {
if(!head) return;
console.log(head.data);
printLinkedList(head.next);
}

Rowadz
Автор

HI, the solution is not working. Current Question is given in this form.
function printLinkedList(head) {
const re = new SinglyLinkedListNode(head);
console.log(re);
}

chetan_nada