leetcode brush 35 title

The third problem is the j today brush 142 LeetCode question, with like 141, it is directly attached to the code

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;
        }
    }

 

Guess you like

Origin www.cnblogs.com/cquer-xjtuer-lys/p/11546142.html
Recommended