【leetcode周赛记录】第78场双周赛+第293场周赛记录

赛后个人排名

leetcode个人资料
在这里插入图片描述

赛题分析总结

第78场双周赛

5299.找到一个数字的K美丽值

class Solution {
public:
	// 模拟即可
    int divisorSubstrings(int num, int k) {
         string s = to_string(num);
        
        int result{};
        int n = s.size();
        for(int i{};i<n-k + 1;++i){
            int tempNum{};
            for(int j{};j<k;++j){
                tempNum = tempNum*10 + (s[i+j]-'0');
            }
            
            if(tempNum != 0 && num % tempNum == 0) result++;
        }
        
        return result;
    }
};

6067.分割数组的方案数

class Solution {
public:
	// 考察前缀和
    int waysToSplitArray(vector<int>& nums) {
        int n = nums.size();
        vector<long long> pre(n+1);
        
        for(int i{};i<n;++i){
            pre[i+1] = pre[i] + nums[i];
        }
        
        long long allSums = pre[n];
        int result{};
        
        for(int i{};i<n-1;++i){
            long long sum1 = pre[i+1];
            long long sum2 = allSums - sum1;
            
            if(sum1 >= sum2) result++;
        }
        
        return result;
    }
};

6068.毯子覆盖的最多白色砖块数

// 未AC
// 后续进行双指针的专项复习、训练以及总结

6069.最大波动的子字符串

直接忽略

第293场周赛

5234.移除字母异位词后的结果数组

class Solution {
public:
	// 模拟求解
    vector<string> removeAnagrams(vector<string>& words) {
        int n = words.size();
        
        vector<int> need1(26);
        vector<int> need2(26);
        
        for(int i{};i<words[0].size();++i){
            need1[words[0][i] - 'a']++;
        }
        
        for(int i{1};i<n;++i){
            for(int j{};j<words[i].size();++j){
                need2[words[i][j] - 'a']++;
            }
            

            
            while(need1 == need2 && i < n){
                words.erase(words.begin()+i);
                need2.clear();
                need2.resize(26,0);
                --n;
                string x = words[i];
                for(int j{};j<x.size();++j){
                    need2[x[j] - 'a']++;
                }
            }
            
            need1 = need2;
            need2.clear();

            need2.resize(26,0);
        }
        
        return words;
    }
};

6064.不含特殊楼层的最大连续楼层数

class Solution {
public:
	// 贪心求解
    int maxConsecutive(int bottom, int top, vector<int>& special) {
        if(special.size() == 0){
            return top-bottom+1;
        }

        sort(special.begin(),special.end());

        int result{};
        int curCount{};

        for(int i{};i< special.size();++i){
            int newTop = special[i];
            curCount = newTop - bottom;

            if(curCount > result){
                result = curCount;  
            } 
            bottom = newTop+1;
        }

        int x = top - bottom +1;

        return max(result,x);
    }
};

6065.按位与结果大于零的最长组合

class Solution {
public:
    int largestCombination(vector<int>& candidates) {
        // 计算从低到高第 k 个二进制位数值为 1 的元素个数
        auto maxlen = [&](int k) -> int {
            int res = 0;
            for (int num: candidates) {
                if (num & (1 << k)) {
                    ++res;
                }
            }
            return res;
        };
        
        int res = 0;
        for (int i = 0; i < 24; ++i) {
            // 遍历二进制位
            res = max(res, maxlen(i));
        }
        return res;
    }
};

6066.统计区间中的整数数目

第四题暂不考虑

反思总结

个人情况

第27、28次参加leetcode竞赛;

总计得到过6次12分,13次7分,9次3分;

后续改进

  1. 双指针的专项复习、训练以及总结系统训练,总结
  2. 位运算的专项复习、训练以及总结系统训练,总结
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

一二三o-0-O

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

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

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

打赏作者

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

抵扣说明:

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

余额充值