For this Question: Given an array of integers, and an integer ‘K’, find the count of pairs of elements in the array whose sum is equal to 'K'.The first line of the input contains 2 space separated integers N and K denoting the size of array and the sum respectively.
The second line of the input contains N space separated integers denoting the elements of the array.

Constraints:
1 <= N <= 100000
1 <= K <= 100000
1 <= A[i] <= 100000Print the count of pairs of elements in the array whose sum is equal to the K.Sample Input:
4 6
1 5 7 1

Sample Output:
2, I have written this Solution Code: import java.io.*; // for handling input/output
import java.util.*; // contains Collections framework

// don't change the name of this class
// you can add inner classes if needed
class Main {
	public static void main (String[] args) {
                      // Your code here
		Scanner sc = new Scanner(System.in);
		int arrSize = sc.nextInt();
		int targetK = sc.nextInt();
		int arr[] = new int[arrSize];

		for(int i = 0; i < arrSize; i++)
			arr[i] = sc.nextInt();
		
		System.out.println(countPairs(arr, arrSize, targetK));
	}

	static long countPairs(int arr[], int arrSize, int targetK)
	{
		long ans = 0;
		HashMap<Integer, Integer> hash = new HashMap<>();
		for(int i = 0; i < arrSize; i++)
		{
			int elem = arr[i];
			if(hash.containsKey(targetK-elem) == true)
				ans += hash.get(targetK-elem);
			
			if(hash.containsKey(elem) == true)
			{
				int freq = hash.get(elem);
				hash.put(elem, freq+1);
			}
			else
				hash.put(elem, 1);
		}

		return ans;
	}
}, In this Programming Language: Java, Now tell me if this Code is compilable or not?