当前位置:网站首页>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))

边栏推荐
- Poj3414 extensive search
- Database recovery strategy
- 华为游戏多媒体调用切换房间方法出现异常Internal system error. Reason:90000017
- Basic grammar of interview (Part 1)
- 大约SQL现场“这包括”与“包括在”字符串的写法
- MySQL连接断开报错MySQLdb._exceptions.OperationalError 4031, The client was disconnected by the server
- Win11运行cmd提示“请求的操作需要提升”的解决方法
- Getting started with microservices (resttemplate, Eureka, Nacos, feign, gateway)
- 从零开始实现lmax-Disruptor队列(四)多线程生产者MultiProducerSequencer原理解析
- Net small and medium-sized enterprise project development framework series (one)
猜你喜欢

"Chris Richardson microservices series" uses API gateway to build microservices

Drawing HSV color wheel with MATLAB

数据泄露怎么办?'华生·K'7招消灭安全威胁

The Blue Bridge Cup web application development simulation competition is open for the first time! Contestants fast forward!

【愚公系列】2022年7月 Go教学课程 004-Go代码注释

Overview of database recovery

华为快游戏调用登录接口失败,返回错误码 -1

Bitbucket installation configuration

MySQL disconnection reports an error MySQL ldb_ exceptions. OperationalError 4031, The client was disconnected by the server

总结出现2xx、3xx、4xx、5xx状态码的原因
随机推荐
资深电感厂家告诉你电感什么情况会有噪音电感噪音是比较常见的一种电感故障情况,如果使用的电感出现了噪音大家也不用着急,只需要准确查找分析出什么何原因,其实还是有具体的方法来解决的。作为一家拥有18年品牌
Win11运行cmd提示“请求的操作需要提升”的解决方法
Official clarification statement of Jihu company
Oracle checkpoint queue - Analysis of the principle of instance crash recovery
Web3为互联网带来了哪些改变?
How to organize an actual attack and defense drill
Create a virtual machine on VMware (system not installed)
K210学习笔记(四) K210同时运行多个模型
他们主动布局(autolayout)环境的图像编辑器
The real situation of programmers
Basic grammar of interview (Part 1)
科技云报道荣膺全球云计算大会“云鼎奖”2013-2022十周年特别贡献奖
Win11缺少dll文件怎么办?Win11系统找不到dll文件修复方法
Analyse des risques liés aux liaisons de microservices
Index optimization of performance tuning methodology
MMAP学习
Database recovery strategy
Oracle views the data size of a table
阿龙的感悟
CRM creates its own custom report based on fetch