Skip to content

Commit

Permalink
Add Link Lists - print reverse order
Browse files Browse the repository at this point in the history
  • Loading branch information
Edward Louie committed Oct 27, 2020
1 parent be96654 commit edfed07
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions Data-Structures/Linked-List/PrintReverse.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* A LinkedList based solution for Printing a List in reverse
*/

function main () {
/*
Problem Statement:
Given a linked list, print the nodes in reverse order.
Link for the Problem: https://leetcode.com/problems/reverse-linked-list/
*/

let head = ''
reverseList(head)
}

reverseList = function (headNode) {
let currentNode = headNode
if (currentNode != null) {
reverseList(currentNode.next)
console.log(currentNode)
}
}

main()

0 comments on commit edfed07

Please sign in to comment.