Skip to content

Commit edfed07

Browse files
author
Edward Louie
committed
Add Link Lists - print reverse order
1 parent be96654 commit edfed07

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* A LinkedList based solution for Printing a List in reverse
3+
*/
4+
5+
function main () {
6+
/*
7+
Problem Statement:
8+
Given a linked list, print the nodes in reverse order.
9+
10+
Link for the Problem: https://leetcode.com/problems/reverse-linked-list/
11+
*/
12+
13+
let head = ''
14+
reverseList(head)
15+
}
16+
17+
reverseList = function (headNode) {
18+
let currentNode = headNode
19+
if (currentNode != null) {
20+
reverseList(currentNode.next)
21+
console.log(currentNode)
22+
}
23+
}
24+
25+
main()
26+

0 commit comments

Comments
 (0)