deno.land / x / masx200_leetcode_test@10.6.5 / linked-list-cycle / index.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import { ListNode } from "../reverse-linked-list/ListNode.ts";
export default function hasCycle(head: ListNode | null): boolean { if (!head) return false; const cache = new Set<ListNode>();
while (head) { if (cache.has(head)) { return true; } else { cache.add(head); } head = head.next; } return false;}
masx200_leetcode_test

Version Info

Tagged at
a year ago