Java solution using streams


#1

import java.util.stream.Collectors;
public class Solution {

public int majorityElement(final List<Integer> A) {
    Map<Integer, List<Integer>> x = A.stream().collect(Collectors.groupingBy(Integer::intValue));
    Integer maxElement = x.entrySet().stream().max(Comparator.comparingInt(kv -> kv.getValue().size())).get().getKey();
    return maxElement.intValue();
}

}