Download 10-week-algorithm-excercise-master/OneQuestionPerDay/LCOF6/reverse_link_node.py from Dorothydu/gitrepo_20: direct link, hf CLI and curl.
- Browser
- Download file 326 Bytes
-
https://huggingface.co/datasets/Dorothydu/gitrepo_20/resolve/main/10-week-algorithm-excercise-master/OneQuestionPerDay/LCOF6/reverse_link_node.py
- Command line
-
hf download hf://datasets/Dorothydu/gitrepo_20/10-week-algorithm-excercise-master/OneQuestionPerDay/LCOF6/reverse_link_node.py
-
curl -L -o reverse_link_node.py https://huggingface.co/datasets/Dorothydu/gitrepo_20/resolve/main/10-week-algorithm-excercise-master/OneQuestionPerDay/LCOF6/reverse_link_node.py
326 Bytes
| from typing import List | |
| class ListNode: | |
| def __init__(self, x): | |
| self.val = x | |
| self.next = None | |
| class Solution: | |
| def reversePrint(self, head: ListNode) -> List[int]: | |
| res = [] | |
| while head is not None: | |
| res.append(head.val) | |
| head = head.next | |
| return res[::-1] |