美文网首页
3 牛客网-剑指offer-从尾到头打印链表

3 牛客网-剑指offer-从尾到头打印链表

作者: 咕叽咕叽_6130 | 来源:发表于2018-10-08 22:04 被阅读0次

    时间限制:1秒 空间限制:32768K 热度指数:682852
    题目描述
    输入一个链表,按链表值从尾到头的顺序返回一个ArrayList。
    参考链接https://www.cnblogs.com/wuguanglin/p/printListFromTailToHead.html

    /function ListNode(x){
    this.val = x;
    this.next = null;
    }
    /
    function printListFromTailToHead(head)
    {
    // write code here
    let res=[],pNode=head;
    while(pNode!=null){
    res.unshift(pNode.val);
    pNode=pNode.next;
    }
    return res;
    }

    相关文章

      网友评论

          本文标题:3 牛客网-剑指offer-从尾到头打印链表

          本文链接:https://www.haomeiwen.com/subject/sxlsaftx.html