【leetcode周赛记录】第80场双周赛记录

赛后个人排名

leetcode个人资料

赛题分析总结

第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分;

后续改进

  1. 二分查找的专项复习、训练以及总结系统训练,总结
  • 4
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

一二三o-0-O

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值