This article is the continuation of one of my previous 9722676707. It is a real task I got during one of job interviews for a Java Daveloper position. This time I will focus not only on possible Java and Scala solutions but I will also present BigData solution. Please stay tuned!

The task you are going to solve is the implementation for the following interface:

public interface Solution {
/**
* Find number of pairs in a given array {@param a} which sum up to the defined number {@param n}
* @param a array of integer >= 0
* @param n sum to which numbers should sum up
* @return number of pairs, we count only combinations(order does not matter) e.g for
* the array {2,3,3,3,4} and n = 6 we have unique pairs {2,3},{2,4},{3,3},{3,4} and only pairs
* {3,3},{2,4} sums up to n = 6 so we return 2. Please notice that we do not take into account repetitions like
* (3,3) and (3,3) or (2,3) and (3,2)
*/
long find(int a[], int n);
}

2049643580