12345678910111213141516171819202122232425 |
- package main
- func main() {
- }
- type ListNode struct {
- Val int
- Next *ListNode
- }
- func reversePrint(head *ListNode) []int {
- var tmpArr []int
- for head != nil {
- tmpArr = append(tmpArr, head.Val)
- head = head.Next
- }
- var ret []int
- for i := len(tmpArr) - 1; i >= 0; i-- {
- ret = append(ret, tmpArr[i])
- }
- return ret
- }
|