Ad
  • Custom User Avatar
    public class LoopDetector{ 
      
      public class Node {
        public Node next {get;set;} 
      }
      
      public static Node createChain(int tailSize, int loopSize){
        var startNode = new Node();
        var currNode = startNode;
        for(var i=0;i<tailSize;i++){
          currNode.next = new Node();
          currNode = currNode.next;
        }
        var loopStartNode = currNode;
        for(var i=0; i<loopSize-1;i++){
          currNode.next = new Node();
          currNode = currNode.next;
        }
        currNode.next = loopStartNode;
        return startNode;
      }
    }
    
  • Custom User Avatar

    I wanted to run this on my local machine, does anyone know what the class LoopDetector looks like please.