MCPcopy Create free account
hub / github.com/PrajaktaSathe/Java / makeLoop

Method makeLoop

Programs/RemoveloopinLinkedList.java:79–95  ·  view source on GitHub ↗
(Node head, int x)

Source from the content-addressed store, hash-verified

77 }
78
79 public static void makeLoop(Node head, int x){
80 if (x == 0)
81 return;
82 Node curr = head;
83 Node last = head;
84
85 int currentPosition = 1;
86 while (currentPosition < x)
87 {
88 curr = curr.next;
89 currentPosition++;
90 }
91
92 while (last.next != null)
93 last = last.next;
94 last.next = curr;
95 }
96
97 public static boolean detectLoop(Node head){
98 Node hare = head.next;

Callers 1

mainMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected