He is kidding me.


  • -1
    7

    /**

    • Definition for singly-linked list.
    • class ListNode {
    • int val;
      
    • ListNode next;
      
    • ListNode(int x) {
      
    •     val = x;
      
    •     next = null;
      
    • }
      
    • }
      */
      public class Solution {
      public boolean hasCycle(ListNode head) {
      ListNode node = head;
      long starttime = System.currentTimeMillis();
      long endtime ;
      while (true){
      if(node!=null)
      node = node.next;
      else return false;
      endtime = System.currentTimeMillis()-starttime;
      if(endtime > 2)
      return true;
      }
      }
      }

  • 1

    You are kidding me


Log in to reply
 

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