HashMap
fxy流年无悔
不要留下太多遗憾
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
HashMap-数组-哈希表-面试题39. 数组中出现次数超过一半的数字
class Solution { public int majorityElement(int[] nums) { Arrays.sort(nums); return nums[nums.length/2]; } } 法二:哈希表c++ class Solution { public: int majorityElement(...原创 2020-04-19 16:37:45 · 303 阅读 · 0 评论 -
HashSet-HashMap-面试题56 - I. 数组中数字出现的次数以后统一用HashMap即可
HashSet: class Solution { public int[] singleNumbers(int[] nums) { HashSet<Integer>set=new HashSet<>(); for(int i:nums){ if(set.contains(i)) ...原创 2020-04-25 10:52:48 · 256 阅读 · 0 评论 -
HashMap-面试题56 - II. 数组中数字出现的次数 II
c++: class Solution { public: int singleNumber(vector<int>& nums) { unordered_map<int,int>mp; for(auto n:nums) mp[n]++; for(auto n:nums){ if...原创 2020-04-24 22:17:41 · 246 阅读 · 0 评论
分享