题目大意:
反向打印链表
给定一个固定链表,利用以下接口倒序打印出链表中的每个节点的值
ImmutableListNode
: 一个链表的接口,题目将给你一个链表头元素的对象
你只能通过以下方式来访问链表
ImmutableListNode.printValue()
: 打印当前节点的数值ImmutableListNode.getNext()
: 返回链表下一个节点
The input is only given to initialize the linked list internally. You must solve this problem without modifying the linked list. In other words, you must operate the linked list using only the mentioned APIs.
Follow up:
Could you solve this problem in:
- Constant space complexity?
- Linear time complexity and less than linear space complexity?