栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

Leetcode 第 293 场周赛

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Leetcode 第 293 场周赛

题目链接 5234. 移除字母异位词后的结果数组
class Solution {
public:
    vector removeAnagrams(vector& s) {
        vectorres;
        res.push_back(s[0]);
        for(int i=1;i
            string a=s[i-1],b=s[i];
            sort(a.begin(),a.end());
            sort(b.begin(),b.end());
            if(a==b)continue;
            res.push_back(s[i]);
        }
        return res;
    }
};
6064. 不含特殊楼层的最大连续楼层数
class Solution {
public:
    int maxConsecutive(int l, int r, vector& a) {
        sort(a.begin(),a.end());
        int res=0;
        res=max(a[0]-l,r-a.back());
        for(int i=1;i 
6065. 按位与结果大于零的最长组合 
class Solution {
public:
    int largestCombination(vector& a) {
        int res=0;
        for(int i=0;i<24;i++)
        {
            int cnt=0;
            for(auto x : a)
            {
                if(x>>i&1)
                    cnt++;
            }
            res=max(res,cnt);
        }
        return res;
    }
};
6066. 统计区间中的整数数目
class CountIntervals {
public:
    int cnt;
    set>s;
    CountIntervals() {
        cnt=0;
    }
    
    void add(int left, int right) {
        auto it=s.lower_bound({left,left});
        if(it!=s.begin())it--;
        int l=left,r=right;
        while(it!=s.end()&&it->first<=right)
        {
            if(it->second
                it++;
                continue;
            }
            l=min(l,it->first);
            r=max(r,it->second);
            cnt-=it->second-it->first+1;
            s.erase(*it);
            it++;
        }
        s.insert({l,r});
        cnt+=r-l+1;
    }
    
    int count() {
        return cnt;
    }
};


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/886991.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号