| 68 | } |
| 69 | |
| 70 | class GFG |
| 71 | { |
| 72 | public static Node newNode(int data){ |
| 73 | Node temp = new Node(); |
| 74 | temp.data = data; |
| 75 | temp.next = null; |
| 76 | return temp; |
| 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; |
| 99 | Node tortoise = head; |
| 100 | while( hare != tortoise ) |
| 101 | { |
| 102 | if(hare==null || hare.next==null) return false; |
| 103 | hare = hare.next.next; |
| 104 | tortoise = tortoise.next; |
| 105 | } |
| 106 | return true; |
| 107 | } |
| 108 | |
| 109 | public static int length(Node head){ |
| 110 | int ret=0; |
| 111 | while(head!=null) |
| 112 | { |
| 113 | ret += 1; |
| 114 | head = head.next; |
| 115 | } |
| 116 | return ret; |
| 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(); |
nothing calls this directly
no outgoing calls
no test coverage detected