题目链接:https://www.nowcoder.com/practice/d0267f7f55b3412ba93bd35cfa8e8035?tpId=13&tqId=11156&rp=1&ru=%2Fta%2Fcoding-interviews&qru=%2Fta%2Fcoding-interviews%2Fquestion-ranking&tab=answerKey 代码: import java.util.ArrayList; public class Solution { public ArrayList<Integer> printListFromTailToHead(ListNode listNode) { if (listNode == null) { return null; } ArrayList<Integer> arr = new ArrayList(); if (listNode.next == null){ arr.add(listNode.val); return arr; } arr = printListFromTailToHead(listNode.next); arr.add(listNode.val); return arr; } } 输入 {67,0,24,58} 版本,Java1.8
点赞 2

相关推荐

牛客网
牛客企业服务