题目:输入一个链表,从尾到头打印链表每个节点的值。思路:遍历链表,插到数组中
1 function printListFromTailToHead(head) 2 { 3 // write code here 4 var current = head; 5 var res = []; 6 while(current!==null){ 7 res.unshift(current.val) 8 current = current.next; 9 } 10 return res; 11 }