首页 > 其他 > 详细

leetcode刷题35

时间:2019-09-19 00:11:19      阅读:91      评论:0      收藏:0      [点我收藏+]

j今天刷的第三道题是LeetCode第142题,跟141很像,就直接贴代码了

public static ListNode solution(ListNode head){
        List<ListNode> list=new ArrayList<>();
        if (head==null||head.next==head)return head;
        ListNode temp=head;
        while (temp!=null&&!list.contains(temp)){
            list.add(temp);
            temp=temp.next;
        }
        if (temp==null)return null;
        else {
            return temp;
        }
    }

 

leetcode刷题35

原文:https://www.cnblogs.com/cquer-xjtuer-lys/p/11546142.html

(1)
(1)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!