You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
val l = new SinglyLinkedList ()
val a = new Node ('a')
val b = new Node ('b')
val c = new Node ('c')
l.head = a
a.next = b
b.next = c
c.next = b
circular(l) // true
Example 2
val l = new List ()
val a = new Node ('a')
circular(l) // false
Hints
Hint 1
We should use more then one variable to store values that are retrieved during iteration (two pointer solution)
Hint 2
Name of these variables should be `slow` and `fast`
Hint 3
Assign next node to `slow` variable in every iteration
Hint 4
Assign next node of next node to `fast` variable in every iteration