For this Question: Given a singly linked list of size <b>N</b>, and an integer <b>K</b>. You need to <b>swap the Kth node from beginning and Kth node from end</b> in linked list.

<b>Note:</b> You need to swap the nodes through the links and not changing the content of the nodes.First line of input contains the number of testcases T. 
The first line of every testacase contains N, number of nodes in linked list and K, the nodes to be swapped and the second line of contains the elements of the linked list.

<b>User task:</b>
The task is to complete the function swapkthnode(), which has arguments head, num(no of nodes) and K, and  it should return new head. The validation is done internally by the driver code to ensure that the swapping is done by changing references/pointers only.  A correct code would always cause output as 1.

<b>Constraints:</b>
1 <= T <= 100
1 <= N <= 10^3
1 <= K <= 10^3For each testcase, if the nodes are swapped correctly, the output will be <b>1</b>, else <b>0</b>.Input:
3
4 1
1 2 3 4
5 3
1 2 3 4 5
4 4
1 2 3 4

Output:
1
1
1

Explanation:
Testcase 1: Here K = 1, hence after swapping the 1st node from beginning and end the new list will be 4 2 3 1.
Testcase 2: Here k = 3, hence after swapping the 3rd node from beginning and end the new list will be 1 2 3 4 5.
Testcase 3: Here k = 4, hence after swapping the 4th node from beginning and end the new list will be 4 2 3 1., I have written this Solution Code: // Should swap Kth node from beginning and Kth
      // node from end in list and return new head.
      static Node swapkthnode(Node head, int num, int K)
    {
        if(K > num) return head;
         if(2*K-1 == num) return head;
    
        Node x_prev = null;
        Node x = head;
    
        Node y_prev = null;
        Node y = head;
    
        int count = K-1;
        while(count-- > 0){
        x_prev = x;
        x = x.next;
        }
    
        count = num - K;
        while(count-- > 0){
        y_prev = y;
        y = y.next;
        }
    
        if(x_prev != null)
            x_prev.next = y;
        if(y_prev != null)
            y_prev.next = x;
        
        Node temp = x.next;
        x.next = y.next;
        y.next = temp;
    
        if(K == 1)
         head = y;
        if(K == num)
            head = x;
        return head;    
    }, In this Programming Language: Java, Now tell me if this Code is compilable or not?