We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0e9b33d commit d5ef0ceCopy full SHA for d5ef0ce
linked-list-cycle/krokerdile.js
@@ -0,0 +1,23 @@
1
+/**
2
+ * Definition for singly-linked list.
3
+ * function ListNode(val) {
4
+ * this.val = val;
5
+ * this.next = null;
6
+ * }
7
+ */
8
+
9
10
+ * @param {ListNode} head
11
+ * @return {boolean}
12
13
+var hasCycle = function(head) {
14
+ let list = new Set();
15
+ while (head != null) {
16
+ if (list.has(head))
17
+ return true;
18
+ list.add(head);
19
+ head = head.next;
20
+ }
21
22
+ return false;
23
+};
0 commit comments