You are viewing a single comment's thread. Return to all comments →
Java 8
static int toys(int[] w) { Arrays.sort(w); int count = 1; int curr = w[0] + 4; for (int i = 1; i < w.length; i++) { if (w[i] > curr) { count++; curr = w[i] + 4; } } return count; }
Seems like cookies are disabled on this browser, please enable them to open this website
Priyanka and Toys
You are viewing a single comment's thread. Return to all comments →
Java 8