• + 0 comments

    Hi everyone, my solution not passing test 5 & 6. Any clue why? Thanks in advance.

        public static List<Integer> cutTheSticks(List<Integer> arr) {
        // Write your code here
            List<Integer> results = new ArrayList<>();
            
            Collections.sort(arr);
            
            results.add(arr.size());
            
            for (int i=1; i < arr.size(); i++) {
                if (arr.get(i) != arr.get(i-1)) {
                  results.add(arr.size()-i);     
                }
            }
             
            return results;
        }