@@ -0,0 +1,753 @@
+package me.wayne.leetcodetop100;%0A%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0A%0A/**%0A * %E7%BB%99%E5%AE%9A%E4%B8%80%E4%B8%AA%E5%A4%A7%E5%B0%8F%E4%B8%BA n %E7%9A%84%E6%95%B0%E7%BB%84%EF%BC%8C%E6%89%BE%E5%88%B0%E5%85%B6%E4%B8%AD%E7%9A%84%E5%A4%9A%E6%95%B0%E5%85%83%E7%B4%A0%E3%80%82%0A * %E5%A4%9A%E6%95%B0%E5%85%83%E7%B4%A0%E6%98%AF%E6%8C%87%E5%9C%A8%E6%95%B0%E7%BB%84%E4%B8%AD%E5%87%BA%E7%8E%B0%E6%AC%A1%E6%95%B0 %E5%A4%A7%E4%BA%8E %E2%8C%8A n/2 %E2%8C%8B %E7%9A%84%E5%85%83%E7%B4%A0%E3%80%82%0A * %3Cp%3E%0A * https://leetcode-cn.com/problems/majority-element/%0A */%0Apublic class LC169_MajorityElement %7B%0A%0A    public int majorityElement(int%5B%5D nums) %7B%0A        Map%3CInteger, Integer%3E map = new HashMap%3C%3E();%0A        for (int num: nums) %7B%0A            Integer value = map.get(num);%0A            map.put(num, value == null ? 1 : ++value);%0A        %7D%0A%0A        int result = 0;%0A        for (Map.Entry%3CInteger, Integer%3E entry : map.entrySet()) %7B%0A            if (entry.getValue() %3E nums.length / 2) %7B%0A                result = entry.getKey();%0A                break;%0A            %7D%0A        %7D%0A%0A        return result;%0A    %7D%0A%7D%0A

add LC169_MajorityElement