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

边栏推荐
- PIP install beatifulsoup4 installation failed
- C language knowledge points link
- 如何向mongoDB中添加新的字段附代码(全)
- Getting started with microservices (resttemplate, Eureka, Nacos, feign, gateway)
- The American Championship is about to start. Are you ready?
- EBS Oracle 11g cloning steps (single node)
- K210 learning notes (IV) k210 runs multiple models at the same time
- Matlab | app designer · I used Matlab to make a real-time editor of latex formula
- Concurrency control of performance tuning methodology
- POJ 3237 tree (tree chain splitting)
猜你喜欢

Oracle advanced query

Serializability of concurrent scheduling

Blocking of concurrency control

Stored procedures and stored functions

How to use tensorflow2 for cat and dog classification and recognition

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

Implementing Lmax disruptor queue from scratch (IV) principle analysis of multithreaded producer multiproducersequencer

Concurrency control of performance tuning methodology

Livelocks and deadlocks of concurrency control

Win11运行cmd提示“请求的操作需要提升”的解决方法
随机推荐
如何组织一场实战攻防演练
深信服X计划-网络协议基础 DNS
Recovery technology with checkpoints
数博会精彩回顾 | 彰显科研实力,中创算力荣获数字化影响力企业奖
大约SQL现场“这包括”与“包括在”字符串的写法
Image editor for their AutoLayout environment
How to use tensorflow2 for cat and dog classification and recognition
U盘的文件无法删除文件怎么办?Win11无法删除U盘文件解决教程
MMAP learning
元宇宙中的三大“派系”
了解 Android Kotlin 中 DataStore 的基本概念以及为什么应该停止在 Android 中使用 SharedPreferences
Official clarification statement of Jihu company
阿龙的感悟
Meituan dynamic thread pool practice ideas, open source
科技云报道:算力网络,还需跨越几道坎?
Oracle views the data size of a table
EL与JSTL注意事项汇总
Interprocess communication in the "Chris Richardson microservice series" microservice architecture
如何開發引入小程序插件
Blocking of concurrency control