当前位置: 首页 > news >正文

公司网站开发项目管理制度acca少女网课视频

公司网站开发项目管理制度,acca少女网课视频,微信公众号创建流程,美国高防云服务器文章目录 前言验证外星语词典在长度 2N 的数组中找出重复 N 次的元素找到小镇的法官查找共用字符数组的相对排序分发饼干分发糖果区间选点(AcWing)最大不相交区间数量(AcWing)无重叠区间关于重写小于号 前言 💫你好,我是辰chen,本文旨在准备考…

文章目录

  • 前言
  • 验证外星语词典
  • 在长度 2N 的数组中找出重复 N 次的元素
  • 找到小镇的法官
  • 查找共用字符
  • 数组的相对排序
  • 分发饼干
  • 分发糖果
  • 区间选点(AcWing)
  • 最大不相交区间数量(AcWing)
  • 无重叠区间
  • 关于重写小于号

前言

💫你好,我是辰chen,本文旨在准备考研复试或就业
💫文章题目大多来自于 leetcode,当然也可能来自洛谷或其他刷题平台
💫欢迎大家的关注,我的博客主要关注于考研408以及AIoT的内容
🌟 仅给出C++版代码

以下的几个专栏是本人比较满意的专栏(大部分专栏仍在持续更新),欢迎大家的关注:

💥ACM-ICPC算法汇总【基础篇】
💥ACM-ICPC算法汇总【提高篇】
💥AIoT(人工智能+物联网)
💥考研
💥CSP认证考试历年题解

验证外星语词典


题目链接:验证外星语词典

C++版AC代码:

class Solution {
public:bool isAlienSorted(vector<string>& words, string order) {unordered_map<char, char> m;// 注意这里相当于重新映射成 a b c d e f g ...for (int i = 0; i < order.size(); i ++ ) m[order[i]] = (char)(i + 'a'); int n = words.size();vector<string> tmp, exch;for (int i = 0; i < n; i ++ ) {string word = words[i], numstr;for (int j = 0; j < word.size(); j ++ ) numstr += m[word[j]];    // 将原字符串映射为按照外星语字典序映射的字符串,即可排序tmp.push_back(numstr), exch.push_back(numstr);  // 分别存到tmp(要排序),exch(对比串)中}sort(tmp.begin(), tmp.end());    // 对tmp进行排序bool flag = true;for (int i = 0; i < n; i ++ ) if (tmp[i] != exch[i]) {     // 有变化即不是按照新字典序有序排列flag = false;break;}return flag;}
};

在长度 2N 的数组中找出重复 N 次的元素


题目链接:在长度 2N 的数组中找出重复 N 次的元素

C++版AC代码:

class Solution {
public:int repeatedNTimes(vector<int>& nums) {unordered_map<int, int> m;int res;for (int i = 0; i < nums.size(); i ++ ) {m[nums[i]] ++;if (m[nums[i]] >= 2) { // 因为有n+1个不同的值,所以当一个元素出现2次的时候就是目标值res = nums[i];break;}}return res;}
};

找到小镇的法官


题目链接:找到小镇的法官

C++版AC代码:

class Solution {
public:int findJudge(int n, vector<vector<int>>& trust) {if (trust.empty() && n == 1) return 1;int judge = -1;unordered_map<int, int> m1;unordered_map<int, bool> m2;for (int i = 0; i < trust.size(); i ++ ) {int fs = trust[i][0], sd = trust[i][1];m1[sd] ++, m2[fs] = false;      // 信任sd的人数+1, fs不可能是法官}for (auto i = m1.begin(); i != m1.end(); i ++ ) {int guy = i -> first, num = i -> second;if ((num == n - 1) && !m2.count(guy)) {judge = guy;break;}}return judge;}
};

查找共用字符


题目链接:查找共用字符

C++版AC代码:

class Solution {
public:vector<string> commonChars(vector<string>& words) {unordered_map<char, int> m;     // 用来记录共用字符,一开始把words[0]存进去for (int i = 0; i < words[0].size(); i ++ ) m[words[0][i]] ++;for (int i = 0; i < words.size(); i ++ ) {string word = words[i];unordered_map<char, int> tmp;         // 存储当前字符串的信息,用来和m做对比for (int j = 0; j < word.size(); j ++ ) tmp[word[j]] ++;for (auto j = m.begin(); j != m.end(); j ++ ) {char s = j -> first;int cnt = j -> second;if (!tmp.count(s)) m[s] = 0;     // tmp中没有这个字符,即不是共用字符,删掉else m[s] = min(cnt, tmp[s]);    // 如果是共用字符则取出现次数为两个串中的最小值}}vector<string> res;for (auto i = m.begin(); i != m.end(); i ++ ) {int cnt = i -> second;while (cnt -- ) res.push_back(string(1, i -> first));// string(1, c) : 把字符c变成字符串格式}return res;}
};

数组的相对排序


题目链接:数组的相对排序

C++版AC代码:

class Solution {
public:vector<int> relativeSortArray(vector<int>& arr1, vector<int>& arr2) {unordered_map<int, int> m;for (int i = 0; i < arr1.size(); i ++ ) m[arr1[i]] ++; vector<int> res, tmp; for (int i = 0; i < arr2.size(); i ++ ) {auto it = m.find(arr2[i]);int k = it -> second;while (k -- ) res.push_back(arr2[i]);   // 按照arr2中的顺序把arr1中的元素存入resit -> second = 0;                       // 标记成已经存储好}for (auto i = m.begin(); i != m.end(); i ++ ) {  // 把arr2中没有的元素暂存到tmp中int k = i -> second;while (k -- ) tmp.push_back(i -> first);}sort(tmp.begin(), tmp.end());       // arr2中没有的元素排序for (int i = 0; i < tmp.size(); i ++ ) res.push_back(tmp[i]);return res;}
};

分发饼干


题目链接:分发饼干

C++版AC代码:

class Solution {
public:int findContentChildren(vector<int>& g, vector<int>& s) {sort(g.begin(), g.end()), sort(s.begin(), s.end());int res = 0;for (int i = 0, j = 0; i < g.size() && j < s.size(); j ++ ) if (g[i] <= s[j]) i ++, res ++;return res;}
};

分发糖果


题目链接:分发糖果

C++版AC代码:

class Solution {
public:int candy(vector<int>& ratings) {int n = ratings.size();vector<int> v(n, 1);         // 开一个长度为n的vector并附初值为1for (int i = 1; i < n; i ++ )     // 从头往后遍历if (ratings[i] > ratings[i - 1]) // 右边比左边大就让右边+1v[i] = v[i - 1] + 1;for (int i = n - 1; i > 0; i -- ) if (ratings[i] < ratings[i - 1])  // 左边比右边大且左边的糖果数≤右边的糖果数就更新+1v[i - 1] = max(v[i - 1], v[i] + 1);return accumulate(v.begin(), v.end(), 0);}
};

区间选点(AcWing)


题目链接:区间选点(AcWing)

C++版AC代码:

#include <cstdio>
#include <iostream>
#include <algorithm>using namespace std;const int N = 100010;struct St{int l, r;bool operator < (const St w) const {      // 按照右端点进行排序return r < w.r;}
}st[N];int main()
{int n;cin >> n;for (int i = 0; i < n; i ++ ) {int l, r;cin >> l >> r;st[i] = {l, r};}sort(st, st + n);int ed = -1e9 - 1, res = 0;for (int i = 0; i < n; i ++ ) {if (st[i].l > ed) {      // 新区间的左端点大于当前区间的右端点,证明这是一个新的区间res ++;              // 区间数 + 1ed = st[i].r;        // 更新为新的右端点}}cout << res;return 0;
}

最大不相交区间数量(AcWing)


题目链接:最大不相交区间数量(AcWing)

C++版AC代码:

同上

#include <iostream>
#include <algorithm>
#include <cstdio>using namespace std;const int N = 100010;struct St {int l, r;bool operator < (const St w) const {return r < w.r;}
}st[N];int main()
{int n;cin >> n;for (int i = 0; i < n; i ++ ) {int l, r;cin >> l >> r;st[i] = {l, r};}sort(st, st + n);int res = 0, ed = -1e9 - 1;for (int i = 0; i < n; i ++ ) if (st[i].l > ed) {res ++;ed = st[i].r;}cout << res;return 0;
}

无重叠区间


题目链接:无重叠区间

C++版AC代码:

class Solution {
public:// 问题等价于求最多的无重叠区间// 贪心思路:按照右端点进行排序,想要最多的无重叠区域,就是在不重叠的时候选择最小的右端点static bool cmp(const vector<int> &a, const vector<int> &b) {return a[1] < b[1];}int eraseOverlapIntervals(vector<vector<int>>& intervals) {sort(intervals.begin(), intervals.end(), cmp);int res = 0, r = -5 * 1e4 - 1;for (int i = 0; i < intervals.size(); i ++ ) {int st = intervals[i][0], ed = intervals[i][1];if (st >= r) {    // 根据例子所述,区间是不包含两个端点的,所以相等的时候也需要更新res ++;r = ed;}}return intervals.size() - res;}
};

关于重写小于号

定义结构体的写法:

struct St {int l, r;bool operator < (const St w) const {return r < w.r;}
}st[N];// 调用无需传入第三个参数:
sort(st, st + n);

关于外部定义的写法:

static bool cmp(const vector<int> &a, const vector<int> &b) {return a[1] < b[1];
}// 调用需要传入第三个参数:
sort(intervals.begin    (), intervals.end(), cmp);

文章转载自:
http://dinncocounter.wbqt.cn
http://dinncoantimechanized.wbqt.cn
http://dinncorepetitive.wbqt.cn
http://dinncoreflorescent.wbqt.cn
http://dinncoadvertise.wbqt.cn
http://dinncohematoxylic.wbqt.cn
http://dinncoudsl.wbqt.cn
http://dinncoadvocate.wbqt.cn
http://dinncovariation.wbqt.cn
http://dinncoincapacious.wbqt.cn
http://dinncopapacy.wbqt.cn
http://dinncoinertialess.wbqt.cn
http://dinncohollowware.wbqt.cn
http://dinncoprying.wbqt.cn
http://dinncomacular.wbqt.cn
http://dinncoextrinsic.wbqt.cn
http://dinncodinosaur.wbqt.cn
http://dinncodistomiasis.wbqt.cn
http://dinncosaratov.wbqt.cn
http://dinncostylostixis.wbqt.cn
http://dinncosiogon.wbqt.cn
http://dinncophasemeter.wbqt.cn
http://dinncocalculably.wbqt.cn
http://dinncoimroz.wbqt.cn
http://dinnconannyish.wbqt.cn
http://dinncocommensal.wbqt.cn
http://dinncoameboid.wbqt.cn
http://dinncosporadic.wbqt.cn
http://dinncocash.wbqt.cn
http://dinncocigaret.wbqt.cn
http://dinncoconviviality.wbqt.cn
http://dinncotrichotomy.wbqt.cn
http://dinncomyna.wbqt.cn
http://dinncomiry.wbqt.cn
http://dinncoautoinoculation.wbqt.cn
http://dinncosporogonium.wbqt.cn
http://dinncoschoolmaster.wbqt.cn
http://dinncovolkswil.wbqt.cn
http://dinncoquartermaster.wbqt.cn
http://dinncorelegate.wbqt.cn
http://dinncosaloonatic.wbqt.cn
http://dinncomerozoite.wbqt.cn
http://dinncoindescribably.wbqt.cn
http://dinncoaffiance.wbqt.cn
http://dinncohumpback.wbqt.cn
http://dinncoinvestigator.wbqt.cn
http://dinncotweese.wbqt.cn
http://dinncorelatively.wbqt.cn
http://dinncoshovelboard.wbqt.cn
http://dinncoheterophobia.wbqt.cn
http://dinncowinnable.wbqt.cn
http://dinnconowanights.wbqt.cn
http://dinncomolecast.wbqt.cn
http://dinncohendiadys.wbqt.cn
http://dinncojapanization.wbqt.cn
http://dinncoboliviano.wbqt.cn
http://dinncoinappreciation.wbqt.cn
http://dinncororty.wbqt.cn
http://dinncoarbitrator.wbqt.cn
http://dinncoupstroke.wbqt.cn
http://dinncofluorescence.wbqt.cn
http://dinncodisassemble.wbqt.cn
http://dinncovacuometer.wbqt.cn
http://dinncovag.wbqt.cn
http://dinncosalpiglossis.wbqt.cn
http://dinncoburglarproof.wbqt.cn
http://dinncoarmomancy.wbqt.cn
http://dinncotern.wbqt.cn
http://dinncohyperfine.wbqt.cn
http://dinncomimeo.wbqt.cn
http://dinncorealtor.wbqt.cn
http://dinncoflue.wbqt.cn
http://dinncofirry.wbqt.cn
http://dinncochopper.wbqt.cn
http://dinncomicroscopical.wbqt.cn
http://dinncochuddar.wbqt.cn
http://dinncofantasticality.wbqt.cn
http://dinncoimpacted.wbqt.cn
http://dinncolubra.wbqt.cn
http://dinncodamiana.wbqt.cn
http://dinncofuji.wbqt.cn
http://dinncoretardee.wbqt.cn
http://dinncosemivitrification.wbqt.cn
http://dinncooropharynx.wbqt.cn
http://dinncohiragana.wbqt.cn
http://dinncoredintegration.wbqt.cn
http://dinncodefamatory.wbqt.cn
http://dinncorailing.wbqt.cn
http://dinncohughie.wbqt.cn
http://dinncoeveryway.wbqt.cn
http://dinncobebeerine.wbqt.cn
http://dinncotrapeze.wbqt.cn
http://dinnconodose.wbqt.cn
http://dinncocarcinoid.wbqt.cn
http://dinncomalaguena.wbqt.cn
http://dinncojrc.wbqt.cn
http://dinncocitified.wbqt.cn
http://dinncosemilanceolate.wbqt.cn
http://dinncoretrocognition.wbqt.cn
http://dinncoquackery.wbqt.cn
http://www.dinnco.com/news/160018.html

相关文章:

  • 东莞网站设计找哪里免费数据统计网站
  • 有效的网站建设公怎么引流怎么推广自己的产品
  • 中国安能建设集团有网站爱站网官网
  • 网站改版做重定向做专业搜索引擎优化
  • 建站工具缺点朝阳网站seo
  • 咸宁制作网站网站建设与管理就业前景
  • 南通住房和城乡建设局网站seo实战教程
  • 青岛网站建设q.479185700強手机百度2020
  • 做网站 分工品牌策划方案范文
  • 做自媒体的有哪些素材网站郑州seo公司
  • angularjs做的网站有哪些店铺推广软文500字
  • 凡客家居亚马逊seo推广
  • 网站建设服务合同是否缴纳印花税百度指数app官方下载
  • java php 网站建设手机网站免费客服系统
  • 陕煤化建设集团网站矿建二公司google关键词搜索技巧
  • 建设网站制作南宁seo主管
  • 做游戏课程网站石家庄疫情最新消息
  • 做好三步网站改版工具不降权 无忧老师今天特大军事新闻
  • 广安发展建设集团官方网站扬州网络优化推广
  • 自己电脑做网站好吗人民日报官网
  • 一个小网站一般多少钱西安建站推广
  • 十堰网站制作公司广州网站优化系统
  • wordpress缓存优化东莞seo网站制作报价
  • 企业没有网站怎么做seo优化今日武汉最新消息
  • 佛山网站建设推广网络营销常用的方法有哪些
  • 北京响应式网站建设报价北京seo软件
  • seo推广哪家公司好朝阳seo建站
  • 郑州网站建设(智巢)google官网登录入口
  • 门户网站建设请示报告谷歌浏览器下载官方正版
  • 保定专门做网站微信朋友圈广告投放收费标准