We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
would this be O(1) // because we know the max size is 100 and O(100) = O(k) = O(1)
booleanhasCycle(Nodehead){if(head==null||head.next==null)returnfalse;Noden=head;// list max size = 100 so after 100 steps if n != null return truefor(inti=0;i<100;i++){if(n==null){returnfalse;}else{n=n.next;}}returntrue;}
Cycle Detection
You are viewing a single comment's thread. Return to all comments →
would this be O(1) // because we know the max size is 100 and O(100) = O(k) = O(1)