You are viewing a single comment's thread. Return to all comments →
java 8 :
public static List<Integer> cutTheSticks(List<Integer> arr) { int count=0; List<Integer> res = new ArrayList<>(); while(arr.size>0){ int sm = Collections.min(arr); for(int j = 0 ; j<arr.size(); j++){ arr.set(j, arr.get(j)-sm); count++; } res.add(count); count = 0; arr = arr.stream().filter(x -> x>0).collect(Collectors.toList()); } return res; }
Seems like cookies are disabled on this browser, please enable them to open this website
Cut the sticks
You are viewing a single comment's thread. Return to all comments →
java 8 :