当前位置:网站首页>Leetcode's 83rd biweekly match
Leetcode's 83rd biweekly match
2022-07-28 01:54:00 【Shirandexiaowo】
summary :
Continue to update the weekly match from today , Include cf、lc and atcoder, The summer camp is going well at present , But I haven't decided where to go yet . etc. 9 I'll tell you when I know the month .
The difficulty of this week's race is relatively simple , But it tests the understanding of data structure
6128. The best poker hand
class Solution:
def bestHand(self, ranks: List[int], suits: List[str]) -> str:
if len(set(suits)) == 1:
return 'Flush'
for i in ranks:
if ranks.count(i) >= 3:
return 'Three of a Kind'
for i in ranks:
if ranks.count(i) == 2:
return 'Pair'
return 'High Card'
2348. whole 0 The number of subarrays
class Solution {
public:
long long zeroFilledSubarray(vector<int>& nums) {
long long ans = 0;
for (int i = 0; i < nums.size(); i ++ ) {
if (nums[i]) continue;
int j = i;
while (j < nums.size() && nums[j] == 0) j ++ ;
int c = j - i;
ans += 1ll * (1 + c) * c / 2;
i = j;
}
return ans;
}
};
2349. Design digital container system
class NumberContainers {
public:
map<int, set<int>> id;
map<int, int> mp;
NumberContainers() {
}
void change(int index, int number) {
if (!mp[index]) {
mp[index] = number;
id[number].insert(index);
}
else {
int t = mp[index];
id[t].erase(index);
mp[index] = number;
id[number].insert(index);
}
}
int find(int number) {
if (id[number].size() == 0)
return -1;
else return *id[number].begin();
}
};
/** * Your NumberContainers object will be instantiated and called as such: * NumberContainers* obj = new NumberContainers(); * obj->change(index,number); * int param_2 = obj->find(number); */
2350. The shortest dice sequence that cannot be obtained
class Solution {
public:
int shortestSequence(vector<int>& rolls, int k) {
set<int> s;
int ans = 0;
for (int u : rolls) {
s.insert(u);
if (s.size() == k) {
s.clear();
ans ++;
}
}
return ans + 1;
}
};
边栏推荐
- 递归的使用:1.将平铺数组转为树 2.将树转化为平铺数组
- “你“想当测试/开发程序员吗?努力发芽的我们......
- 企业运维实践-使用Aliyun容器镜像服务对海外gcr、quay仓库镜像进行镜像拉取构建
- Docker builds MySQL master-slave locally
- Matlab 44 animation gradient drawing programs
- 2022软件测试技能 Robotframework + SeleniumLibrary + Jenkins web关键字驱动自动化实战教程
- My rich second generation friend
- 路由策略简介
- GBase 8c 备份控制函数(四)
- Unity 通用红点系统
猜你喜欢

基于 Flink CDC 实现海量数据的实时同步和转换

How tormenting are weekly and monthly reports? Universal report template recommended collection! (template attached)
![[add pictures to dice roller app]](/img/36/c5c01946bd8c4ea16ebd3f8f9b92b6.png)
[add pictures to dice roller app]

Blizzard Diablo 4 ps5 / PS4 beta added to Playstation database

小散量化炒股记|量化系统中数据是源头,教你搭建一款普适的数据源框架

硬件SPI与软件模拟SPI速率对比

Graph theory analysis of white matter brain function network: neural markers for classification and prediction of depression

面试官:你确定Redis是单线程的进程吗?

Matlab 44 animation gradient drawing programs

Flink 在 讯飞 AI 营销业务的实时数据分析实践
随机推荐
Custom events
LeetCode高频题128. 最长连续序列,经常被互联网大厂面试考到
GBase 8c 恢复控制函数
C # learning notes ----- C # connect to MySQL database
石油化工行业迎战涨价大潮,经销商分销系统平台数字化赋能经销商与门店
LeetCode 第 302 场周赛
[interview: concurrent article 28:volatile] orderliness
A Tiger's Tale
MATLAB 44种动漫渐变色绘图程序
总结:Prometheus存储
For newly installed PIP3, use no module named 'LSB_ Release 'problem
Dpdk plug-in of VPP
Data warehouse construction - DWS floor
小散量化炒股记|量化系统中数据是源头,教你搭建一款普适的数据源框架
牛客多校第三场A,C+权值线段树
FreeRTOS内核小结
js 哪些情况不能用 JSON.parse 、JSON.stringify深拷贝及一个更好的深拷贝方法
集合/容器
Favorite songs
[add pictures to dice roller app]