【leetcode周赛记录】第80场双周赛记录
赛后个人排名
赛题分析总结
第296场周赛
6095.强密码检验器II
class Solution {
public:
bool strongPasswordCheckerII(string password) {
bool a{false},b{false},c{false},d{false};
string l{"!@#$%^&*()-+"};
unordered_map<char,int> unMap;
for(char w : l) unMap[w]++;
if(password.size() < 8){
return false;
}
char cx;
for(int i{};i<password.size();++i){
if(i > 0){
if(password[i] == cx) return false;
}
if(password[i] >= '0' && password[i] <= '9'){
a = true;
}
if(password[i] >= 'a' && password[i] <= 'z'){
b = true;
}
if(password[i] >= 'A' && password[i] <= 'Z'){
c = true;
}
if(unMap[password[i]] > 0){
d = true;
}
cx = password[i];
}
return a && b && c &&d;
}
};
6096.咒语和药水的成功对数
class Solution {
public:
// 使用二分nlogn复杂度求解
vector<int> successfulPairs(vector<int>& spells, vector<int>& potions, long long success) {
sort(potions.begin(),potions.end());
vector<int> result;
int sSize = spells.size();
int pSize = potions.size();
// 在potions中查询第一个大于等于success/spells[i] 的值
for(int i{};i<spells.size();++i){
long long tmp1 = (long long)spells[i] * potions[pSize-1];
if(tmp1 < success){
result.push_back(0);
continue;
}
tmp1 = (long long)spells[i] * potions[0];
if(tmp1 >= success){
result.push_back(pSize);
continue;
}
int target = success/spells[i];
long long p = (long long)target*spells[i];
if(p < success){
target = target+1;
}
result.push_back(pSize-(lower_bound(potions.begin(), potions.end(), target) - potions.begin()));
}
return result;
}
};
6097.替换字符后匹配
困难题
6098.统计得分小于K的子数组数目
第四题暂不考虑
反思总结
个人情况
第32次参加leetcode竞赛;
总计得到过5次12分,1次8分,16次7分,10次3分;
后续改进
- 二分查找的专项复习、训练以及总结系统训练,总结