0
点赞
收藏
分享

微信扫一扫

LeetCode93:复原IP地址

王小沫 2024-04-24 阅读 11

解题思路:

public class Solution {
    public ListNode detectCycle(ListNode head) {
         Set<ListNode> set = new HashSet<>();
        while (head != null) {
            if (!set.add(head)) {
                return head;
            }
            head = head.next;
        }
        return null;
    }
}
举报

相关推荐

0 条评论