Re: [闲聊] 每日LeetCode

楼主: Rushia (みけねこ的鼻屎)   2022-11-30 09:20:23
1207. Unique Number of Occurrences
给予一个整数阵列,若该整数的每个数字出现次数都不重复返回true,否则false。
Example:
Input: arr = [1,2,2,1,1,3]
Output: true
Explanation: The value 1 has 3 occurrences, 2 has 2 and 3 has 1. No two
values have the same number of occurrences.
Input: arr = [1,2]
Output: false
思路:
1.用HashMap统计每个数字的出现次数
2.用Set检查出现次数是否重复
JavaCode:

Links booklink

Contact Us: admin [ a t ] ucptt.com