题解 | #从尾到头打印链表#
从尾到头打印链表
http://www.nowcoder.com/practice/d0267f7f55b3412ba93bd35cfa8e8035
package main type NodeList struct { //使用struct定义一个单向链表 Val int Next *NodeList } func printListFromTailToHead( head *ListNode ) []int { var ans []int if head != nil { ans = append(printListFromTailToHead(head.Next), head.Val) //将每个节点的值添加到切片 } return ans }