Ad
  • Custom User Avatar

    Thanks so much hobosky! Quick question if ya dont mind, where did you find this/did you write it yourself?

    Just asking because I felt like I was missing some information for this kata, and this really helps me understand the class we are working with

  • 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;
      }
    }