Download 10-week-algorithm-excercise-master/OneQuestionPerDay/LCOF6/reverse_link_node.go from Dorothydu/gitrepo_20: direct link, hf CLI and curl.
- Browser
- Download file 300 Bytes
-
https://huggingface.co/datasets/Dorothydu/gitrepo_20/resolve/main/10-week-algorithm-excercise-master/OneQuestionPerDay/LCOF6/reverse_link_node.go
- Command line
-
hf download hf://datasets/Dorothydu/gitrepo_20/10-week-algorithm-excercise-master/OneQuestionPerDay/LCOF6/reverse_link_node.go
-
curl -L -o reverse_link_node.go https://huggingface.co/datasets/Dorothydu/gitrepo_20/resolve/main/10-week-algorithm-excercise-master/OneQuestionPerDay/LCOF6/reverse_link_node.go
300 Bytes
| package main | |
| type ListNode struct { | |
| Val int | |
| Next *ListNode | |
| } | |
| func reversePrint(head *ListNode) []int { | |
| var res []int | |
| for head != nil { | |
| res = append(res, head.Val) | |
| head = head.Next | |
| } | |
| for i, j := 0, len(res)-1; i < j; i, j = i+1, j-1 { | |
| res[i], res[j] = res[j], res[i] | |
| } | |
| return res | |
| } | |