Simple JavaScript solution (beats 82% of other submittion)


  • 0
    M
    var hasCycle = function(head) {    
        while(head){
            if(head.val){
                head.val = false;
                head = head.next;
            }else{
                return true;
            }            
        }
        
        return false;
    };
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.