MCPcopy Create free account
hub / github.com/Ayush7614/Daily-Coding-DS-ALGO-Practice / main

Method main

Gfg/Java/Delete_Loop_from_LL.java:84–112  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

82 }
83
84 public static void main(String[] args) {
85 Scanner sc = new Scanner(System.in);
86 int t = sc.nextInt();
87
88 while (t-- > 0) {
89 int n = sc.nextInt();
90
91 int num = sc.nextInt();
92 Node head = newNode(num);
93 Node tail = head;
94
95 for (int i = 0; i < n - 1; i++) {
96 num = sc.nextInt();
97 tail.next = newNode(num);
98 tail = tail.next;
99 }
100
101 int pos = sc.nextInt();
102 makeLoop(head, pos);
103
104 ans x = new ans();
105 x.removeLoop(head);
106
107 if (detectLoop(head) || length(head) != n)
108 System.out.println("0");
109 else
110 System.out.println("1");
111 }
112 }
113}
114// } Driver Code Ends
115

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