当前位置:网站首页>Une explication du 80e match bihebdomadaire de leetcode
Une explication du 80e match bihebdomadaire de leetcode
2022-06-12 05:57:00 【Vain957】
A& 6095. Détecteur de mot de passe fort II
Simulation simple:
class Solution {
public:
bool strongPasswordCheckerII(string pd) {
unordered_map<char,bool>vis;
string a="[email protected]#$%^&*()-+";
for(int i=0;i<a.size();i++){
vis[a[i]]=true;
}
int jp=0;
int n=pd.size();
if(n<8){
return false;
}
for(int i=0;i+1<n;i++){
if(pd[i]==pd[i+1]){
return false;
}
}
for(int i=0;i<n;i++){
if(pd[i]>='a'&&pd[i]<='z'){
jp++;
break;
}
}
for(int i=0;i<n;i++){
if(pd[i]>='0'&&pd[i]<='9'){
jp++;
break;
}
}
for(int i=0;i<n;i++){
if(pd[i]>='A'&&pd[i]<='Z'){
jp++;
break;
}
}
for(int i=0;i<n;i++){
if(vis[pd[i]]){
jp++;
break;
}
}
return jp==4;
}
};
B& 6096. Le nombre de sorts et de potions réussis
Trier deux points
class Solution {
public:
static bool cmp(pair<int,int>&a,pair<int,int>&b){
return a.first<b.first;
}
vector<int> successfulPairs(vector<int>& spells, vector<int>& potions, long long success) {
vector<pair<int,int>>pir;
for(int i=0;i<spells.size();i++){
pir.push_back(make_pair(spells[i],i));
}
sort(pir.begin(),pir.end(),cmp);
sort(potions.begin(),potions.end());
vector<int>ans(pir.size(),0);
int n=potions.size();
for(int i=0;i<pir.size();i++){
long long aim=(success%pir[i].first!=0)+success/pir[i].first; int sum=aim>(long long)INT_MAX?0:(n-(lower_bound(potions.begin(),potions.end(),aim)-potions.begin()));
ans[pir[i].second]=sum;
}
return ans;
}
};
C& 6097. Correspondance après remplacement des caractères
Simulation de violence
Il y a un problème avec le titre chinois
class Solution {
public:
bool matchReplacement(string s, string sub, vector<vector<char>>& mappings) {
unordered_map<char,vector<char>>mp;
for(int i=0;i<mappings.size();i++){
mp[mappings[i][0]].push_back(mappings[i][1]);
}
for(int i=0;i+sub.size()-1<s.size();i++){
bool t=true;
for(int j=0;j<sub.size();j++){
if(s[i+j]!=sub[j]){
auto it =find(mp[sub[j]].begin(),mp[sub[j]].end(),s[i+j]);
if(it==mp[sub[j]].end()){
t=false;
break;
}
}
}
if(t){
return true;
}
}
return false;
}
};
D& 6098. Score statistique inférieur à K Nombre de sous - tableaux pour
Calcul mathématique
class Solution {
public:
long long countSubarrays(vector<int>& nums, long long k) {
long long sum=0,l=0,ans=0;
for(int i=0;i<nums.size();i++){
sum+=nums[i];
long long t=sum*(i-l+1);
while(t>=k&&l<=i){
sum-=nums[l];
l++;
t=sum*(i-l+1);
}
ans+=i-l+1;
}
return ans;
}
};
边栏推荐
- nrf52832--官方例程ble_app_uart添加led特性,实现电脑uart和手机app控制开发板led开和关
- [go] Viper reads the configuration file in the go project
- The relation between virtual function and pure virtual function
- 三年磨一剑:蚂蚁金服的研发效能洞察实践
- Unable to access this account. You may need to update your password or grant the account permission to synchronize to this device. Tencent corporate email
- A preliminary understanding of function
- A month's worth of DDD will help you master it
- Word frequency statistics using Jieba database
- Stack and queue classic interview questions
- EBook upload
猜你喜欢

Data integration framework seatunnel learning notes

个人申请OV类型SSL证书

Halcon 3D 深度图转换为3D图像

Thesis reading_ Figure neural network gin

TCP and UDP introduction

Special materials | household appliances, white electricity, kitchen electricity

Introduction to sringmvc

EBook list page

Redis persistence

IO stream introduction
随机推荐
Word frequency statistics using Jieba database
XML参数架构,同一MTK SW版本兼容两套不同的音频参数
Redis persistence
User login 【 I 】
What is the difference between ArrayList and LinkedList?
Greenplum [question 05] Greenplum streaming server custom client problem handling (increasing)
Webrtc AEC process analysis
Conversion of Halcon 3D depth map to 3D image
Nrf52832 services et fonctionnalités personnalisés
项目开发流程简单介绍
基于tensorflow的校园绿植识别
Halcon 3D 深度图转换为3D图像
基于LFFD模型目标检测自动标注生成xml文件
How much Ma is the driving current of SIM card signal? Is it adjustable?
登录验证过滤器
数据库实验二:数据更新
MySQL master-slave, 6 minutes to master
[gpio] how to modify / display GPIO status through ADB shell
About architecture (in no particular order)
EBook upload