@@ -0,0 +1,2221 @@
+package org.pilgrim.leetcode.y2022;%0A%0Apublic class ThreeSumFast %7B%0A%0A    // Do not instantiate.%0A    private ThreeSumFast() %7B %7D%0A%0A    // returns true if the sorted array a%5B%5D contains any duplicated integers%0A    private static boolean containsDuplicates(int%5B%5D a) %7B%0A        for (int i = 1; i %3C a.length; i++)%7B%0A          if (a%5Bi%5D == a%5Bi-1%5D)%7B%0A            return true;%0A          %7D%0A        %7D%0A      %0A        return false;%0A    %7D%0A%0A    /**%0A     * Prints to standard output the (i, j, k) with %7B@code i %3C j %3C k%7D%0A     * such that %7B@code a%5Bi%5D + a%5Bj%5D + a%5Bk%5D == 0%7D.%0A     *%0A     * @param a the array of integers%0A     * @throws IllegalArgumentException if the array contains duplicate integers%0A     */%0A    public static void printAll(int%5B%5D a) %7B%0A        int n = a.length;%0A        Arrays.sort(a);%0A        if (containsDuplicates(a)) throw new IllegalArgumentException(%22array contains duplicate integers%22);%0A        for (int i = 0; i %3C n; i++) %7B%0A            for (int j = i+1; j %3C n; j++) %7B%0A                int k = Arrays.binarySearch(a, -(a%5Bi%5D + a%5Bj%5D));%0A                if (k %3E j) StdOut.println(a%5Bi%5D + %22 %22 + a%5Bj%5D + %22 %22 + a%5Bk%5D);%0A            %7D%0A        %7D%0A    %7D%0A%0A    /**%0A     * Returns the number of triples (i, j, k) with %7B@code i %3C j %3C k%7D%0A     * such that %7B@code a%5Bi%5D + a%5Bj%5D + a%5Bk%5D == 0%7D.%0A     *%0A     * @param a the array of integers%0A     * @return the number of triples (i, j, k) with %7B@code i %3C j %3C k%7D%0A     * such that %7B@code a%5Bi%5D + a%5Bj%5D + a%5Bk%5D == 0%7D%0A     */%0A    public static int count(int%5B%5D a) %7B%0A        int n = a.length;%0A        Arrays.sort(a);%0A        if (containsDuplicates(a)) throw new IllegalArgumentException(%22array contains duplicate integers%22);%0A        int count = 0;%0A        for (int i = 0; i %3C n; i++) %7B%0A            for (int j = i+1; j %3C n; j++) %7B%0A                int k = Arrays.binarySearch(a, -(a%5Bi%5D + a%5Bj%5D));%0A                if (k %3E j) count++;%0A            %7D%0A        %7D%0A        return count;%0A    %7D%0A%0A    /**%0A     * Reads in a sequence of distinct integers from a file, specified as a command-line argument;%0A     * counts the number of triples sum to exactly zero; prints out the time to perform%0A     * the computation.%0A     *%0A     * @param args the command-line arguments%0A     */%0A    public static void main(String%5B%5D args)  %7B%0A    %7D%0A%7D%0A

Create ThreeSumFast.java