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

Method main

Programs/RemoveloopinLinkedList.java:119–149  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

117 }
118
119 public static void main (String[] args){
120 Scanner sc = new Scanner(System.in);
121 int t = sc.nextInt();
122
123 while(t--> 0)
124 {
125 int n = sc.nextInt();
126
127 int num = sc.nextInt();
128 Node head = newNode(num);
129 Node tail = head;
130
131 for(int i=0; i<n-1; i++)
132 {
133 num = sc.nextInt();
134 tail.next = newNode(num);
135 tail = tail.next;
136 }
137
138 int pos = sc.nextInt();
139 makeLoop(head, pos);
140
141 Solution x = new Solution();
142 x.removeLoop(head);
143
144 if( detectLoop(head) || length(head)!=n )
145 System.out.println("0");
146 else
147 System.out.println("1");
148 }
149 }
150}

Callers

nothing calls this directly

Calls 5

newNodeMethod · 0.95
makeLoopMethod · 0.95
removeLoopMethod · 0.95
detectLoopMethod · 0.95
lengthMethod · 0.95

Tested by

no test coverage detected