• + 0 comments
        public static List<Integer> stones(int n, int a, int b) {
            Set<Integer> resultsSet = new HashSet<>();
            for (int i = 0; i < n; i++) {
                resultsSet.add(i * a + (n - i - 1) * b);
            }
            Integer[] resultsArray = new Integer[resultsSet.size()];
            resultsSet.toArray(resultsArray);
            Arrays.sort(resultsArray);
            return Arrays.asList(resultsArray);
        }