public static int[] innerUnion(int[] firstArr, int[] secondArr) {
        if (firstArr == null || secondArr == null) {
            return new int[]{};
        }

        int[] _firstArr = firstArr.clone();
        int[] _secondArr = secondArr.clone();

        Arrays.sort(_firstArr);
        Arrays.sort(_secondArr);
        int[] innerUnion = null;
        int traceIndex = 0;
        int peersCounter = 0;
        for (int elem : _firstArr) {
            int position = Arrays.binarySearch(_secondArr, elem);
            if (position >= 0)
                peersCounter++;
        }

        innerUnion = new int[peersCounter];
        for (int elem : _firstArr) {
            int position = Arrays.binarySearch(_secondArr, elem);
            if (position >= 0) {
                innerUnion[traceIndex++] = _secondArr[position];

            }
        }

        return innerUnion;

    }