You are viewing a single comment's thread. Return to all 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); }
Seems like cookies are disabled on this browser, please enable them to open this website
Manasa and Stones
You are viewing a single comment's thread. Return to all comments →