From c2abc60d4a8d6a76e7215f383b51e4c82c7503db Mon Sep 17 00:00:00 2001 From: anujkhaire <46042959+anujkhaire@users.noreply.github.com> Date: Thu, 4 Feb 2021 14:41:43 +0530 Subject: [PATCH] overflow: (nums/2)=>(nums.lenght>>>1) --- company/adobe/MajorityElement.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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);