Answers for "Linked list hasCycle"

0

Linked list hasCycle

var hasCycle = function(head) {
    let currentNode = head
    while(currentNode !== null) {
        if(currentNode.val === null) return true
        currentNode.val = null
        currentNode = currentNode.next
    }
    return false
};
Posted by: Guest on April-22-2022

Browse Popular Code Answers by Language