From edfed07a94394f35662ac9eabe4f0747db08c950 Mon Sep 17 00:00:00 2001 From: Edward Louie Date: Tue, 27 Oct 2020 16:25:00 -0600 Subject: [PATCH] Add Link Lists - print reverse order --- Data-Structures/Linked-List/PrintReverse.js | 26 +++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Data-Structures/Linked-List/PrintReverse.js diff --git a/Data-Structures/Linked-List/PrintReverse.js b/Data-Structures/Linked-List/PrintReverse.js new file mode 100644 index 0000000000..03a518cb42 --- /dev/null +++ b/Data-Structures/Linked-List/PrintReverse.js @@ -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() +