For this Question: You are given head which is a reference node to a doubly- linked list of integers and an integer K. Complete the function <b>swapNodes</b> which swaps the values of nodes at distance K from beginning and end. The first node is at distance 1 from beginning.User task:
Since this will be a functional problem, you don't have to take input. You just have to complete the function <b>swapNodes</b> that takes the head of the linked list and node distance K as parameters.

Constraints:
1 <= Number of nodes <= 10000.
1 <= K <= Number of nodesThe function need not return anything.Sample Input 1:-
5 2
1 2 3 4 5

Sample Output 1:-
1 4 3 2 5

Explanation:
The node at distance 2 from beginning is 2.
The node at distance 2 from end is 4.
We will swap 2 and 4.

Sample Input 2:-
3 2
1 2 3

Sample Output 2:-
1 2 3

Explanation:
The node at distance 2 from beginning is 2.
The node at distance 2 from end is 2.
We will swap 2 and 2. So, the linked list remains as it is., I have written this Solution Code: static void swapNodes(Node head,int k)
    {
        Node temp=head;
        while(temp.next!=null)temp=temp.next;
        k--;
        while(k>0){
            head=head.next;
            temp=temp.prev;
            k--;
        }
        int f=temp.data;
        temp.data=head.data;
        head.data=f;
    }, In this Programming Language: Java, Now tell me if this Code is compilable or not?