public static boolean checkSumUsingSort(int[] A, int x) {	// Time complexity - O(nlog(n))
		if(A == null || A.length < 2)
			return false;
		int i, j, flag = 0;
		int left = 0, right = A.length - 1;
		java.util.Arrays.sort(A);
		while(left < right) {
			i = A[left];
			j = A[right];
			if(i + j == x) {
				System.out.println("Pair " + i + ", " + j + " has sum " + x);
				flag = 1;
				left++;
				right--;
			}
			else if(i + j < x) 
				left++;
			else
				right--;
		}
		if(flag == 1)
			return true;
		return false;
	}