@@ -0,0 +1,2763 @@
+import java.io.BufferedReader;%0Aimport java.io.IOException;%0Aimport java.io.InputStreamReader;%0A%0Aimport java.util.Map;%0Aimport java.util.HashMap;%0A%0A// https://www.hackerrank.com/challenges/pairs/problem%0Apublic class Pairs %7B%0A%0A    private static final String SPACE = %22 %22;%0A%0A    private static long%5B%5D getArray(int size, BufferedReader reader) throws IOException %7B%0A        String line = reader.readLine();%0A        String%5B%5D split = line.split(SPACE);%0A        long%5B%5D numbers = new long%5Bsize%5D;%0A        if (split.length != size) %7B%0A            throw new IllegalStateException(%22The given size and the size of %22 +%0A                    %22the array given as input does not match.%22);%0A        %7D%0A        for (int i = 0; i %3C size; i++) %7B%0A            numbers%5Bi%5D = Long.parseLong(split%5Bi%5D);%0A        %7D%0A        return numbers;%0A    %7D%0A%0A    /**%0A     * Given an array of longs, returns a map with each element in the%0A     * array as a key.%0A     *%0A     * Complexity: O(n)%0A     *%0A     * @param numbers Array of longs.%0A     * @return Map with each element in the array as a key.%0A     */%0A    private static Map%3CLong, Boolean%3E getNumbersMap(long%5B%5D numbers) %7B%0A        Map%3CLong, Boolean%3E map = new HashMap%3C%3E();%0A        for (long number : numbers) %7B%0A            map.put(number, true);%0A        %7D%0A        return map;%0A    %7D%0A%0A    /**%0A     * Get amount of pairs in the array whose difference is equal to the target.%0A     *%0A     * Complexity: O(n)%0A     *%0A     * @param target Number we need to obtain as a result of the difference%0A     *               between two numbers in the given array.%0A     * @param numbers Array we use to find two numbers whose difference is%0A     *                equal to the target.%0A     * @return Amount of pairs in the array whose difference is%0A     *         equal to the target.%0A     */%0A    private static int getPairsToReachTarget(long target, long%5B%5D numbers) %7B%0A        int pairs = 0;%0A        Map%3CLong, Boolean%3E numbersMap = getNumbersMap(numbers);%0A        for (long number : numbers) %7B%0A            long numberToReachTarget = number + target;%0A            boolean numberExists = numbersMap.getOrDefault(numberToReachTarget, false);%0A            if (numberExists) %7B%0A                pairs++;%0A            %7D%0A        %7D%0A        return pairs;%0A    %7D%0A%0A    public static void main(String%5B%5D args) throws IOException %7B%0A        try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) %7B%0A            String line = reader.readLine();%0A            String%5B%5D split = line.split(SPACE);%0A            int arraySize = Integer.parseInt(split%5B0%5D);%0A            long target = Long.parseLong(split%5B1%5D);%0A            long%5B%5D numbers = getArray(arraySize, reader);%0A            int pairs = getPairsToReachTarget(target, numbers);%0A            System.out.println(pairs);%0A        %7D%0A    %7D%0A%7D%0A

Add solution for Pairs problem.