We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f66ef84 commit 5d5349bCopy full SHA for 5d5349b
1265-print-immutable-linked-list-in-reverse.js
@@ -0,0 +1,31 @@
1
+/**
2
+ * // This is the ImmutableListNode's API interface.
3
+ * // You should not implement it, or speculate about its implementation.
4
+ * function ImmutableListNode() {
5
+ * @ return {void}
6
+ * this.printValue = function() { // print the value of this node.
7
+ * ...
8
+ * };
9
+ *
10
+ * @return {ImmutableListNode}
11
+ * this.getNext = function() { // return the next node.
12
13
14
15
+ */
16
+
17
18
+ * @param {ImmutableListNode} head
19
+ * @return {void}
20
21
+var printLinkedListInReverse = function(head) {
22
+ dfs(head)
23
+ function dfs(node) {
24
+ if(node.getNext() == null) {
25
+ node.printValue()
26
+ return
27
+ }
28
+ dfs(node.getNext())
29
30
31
+};
0 commit comments