当前位置:网站首页>Unique occurrence times of leetcode simple questions
Unique occurrence times of leetcode simple questions
2022-07-05 22:03:00 【·Starry Sea】
subject
Give you an array of integers arr, Please help count the number of occurrences of each number in the array .
If the number of occurrences of each number is unique , Just go back to true; Otherwise return to false.
Example 1:
Input :arr = [1,2,2,1,1,3]
Output :true
explain : In this array ,1 There is 3 Time ,2 There is 2 Time ,3 Only appeared. 1 Time . No two numbers appear the same number .
Example 2:
Input :arr = [1,2]
Output :false
Example 3:
Input :arr = [-3,0,1,-3,1,1,1,-3,10,0]
Output :true
Tips :
1 <= arr.length <= 1000
-1000 <= arr[i] <= 1000
source : Power button (LeetCode)
Their thinking
First, count the frequency of elements , Then the frequency is de duplicated , If there is no change after weight removal , Then the number of occurrences is unique .
class Solution:
def uniqueOccurrences(self, arr: List[int]) -> bool:
return len(set(Counter(arr).values()))==len(Counter(arr))
边栏推荐
- An exception occurred in Huawei game multimedia calling the room switching method internal system error Reason:90000017
- Advantages and disadvantages of the "Chris Richardson microservice series" microservice architecture
- [Yugong series] go teaching course in July 2022 004 go code Notes
- Recovery technology with checkpoints
- 深信服X计划-网络协议基础 DNS
- How to use tensorflow2 for cat and dog classification and recognition
- Detailed explanation of memset() function usage
- Defect detection - Halcon surface scratch detection
- 大约SQL现场“这包括”与“包括在”字符串的写法
- Image editor for their AutoLayout environment
猜你喜欢
华为联机对战如何提升玩家匹配成功几率
Defect detection - Halcon surface scratch detection
Dbeaver executes multiple insert into error processing at the same time
Ad637 notes d'utilisation
Database recovery strategy
"Chris Richardson microservices series" uses API gateway to build microservices
The American Championship is about to start. Are you ready?
AD637使用笔记
Type of fault
U盘的文件无法删除文件怎么办?Win11无法删除U盘文件解决教程
随机推荐
Huawei cloud modelarts text classification - takeout comments
MySQL连接断开报错MySQLdb._exceptions.OperationalError 4031, The client was disconnected by the server
Meituan dynamic thread pool practice ideas, open source
regular expression
Codeforces 12D Ball 树形阵列模拟3排序元素
科技云报道荣膺全球云计算大会“云鼎奖”2013-2022十周年特别贡献奖
Blocking protocol for concurrency control
Blocking of concurrency control
C language knowledge points link
【愚公系列】2022年7月 Go教学课程 004-Go代码注释
MMAP学习
Summary of El and JSTL precautions
MySQL disconnection reports an error MySQL ldb_ exceptions. OperationalError 4031, The client was disconnected by the server
Dbeaver executes multiple insert into error processing at the same time
NET中小型企业项目开发框架系列(一个)
Huawei fast game failed to call the login interface, and returned error code -1
The American Championship is about to start. Are you ready?
Interprocess communication in the "Chris Richardson microservice series" microservice architecture
Livelocks and deadlocks of concurrency control
等到产业互联网时代真正发展成熟,我们将会看待一系列的新产业巨头的出现