leetcode-141 環形鏈表(LinkedListCycle)-java

題目:環形鏈表 給定一個鏈表,判斷鏈表中是否有環。 進階: 你能否不使用額外空間解決此題? public boolean hasCycle(ListNode head) { if (head == null || head.next == null) return false; ListNode fast = head; ListNode slow = he
相關文章
相關標籤/搜索