You are viewing a single comment's thread. Return to all comments →
Java:
public static int toys(List<Integer> w) { Collections.sort(w); int n = w.size(); int containerCount = 1; int minUnit = w.get(0); for(int i = 1; i < n; i++ ) { if(w.get(i) > minUnit + 4) { minUnit = w.get(i); containerCount++; } } return containerCount; } }
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: