第 30 日:数组中数字出现的次数 II
题目链接:https://leetcode-cn.com/problems/shu-zu-zhong-shu-zi-chu-xian-de-ci-shu-ii-lcof/
题目
解题
-
Map集合
解题思路:
使用集合,有手就行
详细代码如下:
class Solution {
// 使用 HashMap 记录各个数字出现的次数
public int singleNumber(int[] nums) {
Map<Integer, Integer> map = new HashMap();
for