diff --git a/company/adobe/MajorityElement.java b/company/adobe/MajorityElement.java index 4fbb79b6..4c64ff08 100644 --- a/company/adobe/MajorityElement.java +++ b/company/adobe/MajorityElement.java @@ -7,9 +7,9 @@ public int majorityElement(int[] nums) { return nums[0]; } - HashMap map = new HashMap(); + HashMap map = new HashMap<>(); for(int current: nums) { - if(map.containsKey(current) && map.get(current) + 1 > nums.length / 2) { + if(map.containsKey(current) && map.get(current) + 1 > nums.length >>> 1) { return current; } else if(map.containsKey(current)) { map.put(current, map.get(current) + 1);