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 }