Skip to content

Commit 0b49d70

Browse files
authored
linked list cycle solution with comment
1 parent 29ec6d3 commit 0b49d70

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

linked-list-cycle/yhkee0404.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
func hasCycle(head *ListNode) bool {
99
u := head
1010
v := head
11-
for u != nil && v != nil {
11+
for u != nil && v != nil { // T(n) = O(n), S(n) = O(1)
1212
u = u.Next
1313
if (u == nil) {
1414
break
1515
}
16-
u = u.Next
16+
u = u.Next // https://hyp.is/gLsBIOHBEe6E_9M9T5MJNw/yhkee0404.github.io/posts/algorithms/leetcode/linked-list-cycle/
1717
v = v.Next
1818
if u == v {
1919
return true

0 commit comments

Comments
 (0)