# """
# This is the ImmutableListNode's API interface.
# You should not implement it, or speculate about its implementation.
# """
# class ImmutableListNode:
# def printValue(self) -> None: # print the value of this node.
# def getNext(self) -> 'ImmutableListNode': # return the next node.
class Solution:
def printLinkedListInReverse(self, head: 'ImmutableListNode') -> None:
ans=[]
while head:
ans.append(head)
head=head.getNext()
for h in ans[::-1]:
h.printValue()
'알고리즘 문제 > Leetcode' 카테고리의 다른 글
1302. Deepest Leaves Sum (0) | 2023.04.11 |
---|---|
1570. Dot Product of Two Sparse Vectors (0) | 2023.04.11 |
209. Minimum Size Subarray Sum (0) | 2023.04.04 |
229. Majority Element II (0) | 2023.04.04 |
287. Find the Duplicate Number (0) | 2023.04.04 |