剑指 Offer 06. 从尾到头打印链表
难度简单
题解:输入一个链表的头节点,从尾到头反过来返回每个节点的值(用数组返回)。
示例 1:
输入:head = [1,3,2] 输出:[2,3,1]
class Solution {
public int[] reversePrint(ListNode head) {
linkedList A=new linkedList();
while(head!=null){
A.add(head.val);
// head = head.next;
head = head.next;
}
int [] arr=new int[A.size()];
for(int i=0;i
ps:用作打卡复习,欢迎指点,不喜勿喷!



