Java No extra space - assign a value


  • 0
    S

    public boolean hasCycle(ListNode head)
    {
    for(ListNode node = head; node!=null; node = node.next)
    {
    if(node.val == Integer.MIN_VALUE){
    return true;
    }
    node.val = Integer.MIN_VALUE;
    }

      return false;
    

    }


Log in to reply
 

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