LeetCode 141 環形鏈表

一:題目   二:解法 運用快慢指針,如果兩指針相遇,則有環。 public class Solution { public boolean hasCycle(ListNode head) { ListNode slow=head; ListNode fast=head; while(fast!=null&&fast.next!=null){
相關文章
相關標籤/搜索