For this Question: You are given <b>head</b> which is a reference node to a doubly- linked list of distinct integers and an integer K. Complete the function <b>pairSum</b> which returns the number of pairs whose sum is equal to K.User task:
Since this will be a functional problem, you don't have to take input. You just have to complete the function <b>pairSum</b> that takes the head of the linked list and integer K as parameters.

Constraints:
1 <= Number of nodes <= 1000.
0 <= K <= 10^5Return an integer- the number of pairs whose sum is equal to K.Sample Input 1:-
3 5
1 2 3

Sample Output 1:-
1

Explanation
2 + 3 = 5
So, there is only one pair

Sample Input 2:-
3 6
1 2 3

Sample Output 2:-
0

Explanation:
There are no pairs which sum to 6, I have written this Solution Code: static int pairSum( Node head, int x)
    {
        int ans=0;
        Node temp=head;
        while(temp!=null){
            Node temp2=temp.next;
            while(temp2!=null){
                if((temp.data+temp2.data)==x)ans++;
                temp2=temp2.next;
            }
            temp=temp.next;
        }
    	return ans;
    }, In this Programming Language: Java, Now tell me if this Code is compilable or not?