1265. Print Immutable Linked List in Reverse

Problem

Print all values of an ImmutableListNode linked list in reverse order using the getNext() and printValue() APIs.

You are given a read-only linked list with the following API:

  • getValue(): Returns the value at the current node
  • getNext(): Returns the next node in the list

Print the values of the linked list in reverse order. You cannot modify the linked list.

Examples
Input: [1,2,3,4]
Output: [4,3,2,1]
Hints
Related Problems

1265. Print Immutable Linked List in Reverse

Print all values of an ImmutableListNode linked list in reverse order using the getNext() and printValue() APIs.