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

ppt做的比较好的网站有哪些app推广软件有哪些

ppt做的比较好的网站有哪些,app推广软件有哪些,莱西网站建设,邢台做网站优化2024/5/24 Day38 greedy 435. 无重叠区间 763.划分字母区间 56. 合并区间 遇到两个维度权衡的时候,一定要先确定一个维度,再确定另一个维度。如果两个维度一起考虑一定会顾此失彼。 重叠区间问题 435. 无重叠区间 题目链接 435 给定一个区间的集合 i…

2024/5/24 Day38 greedy 435. 无重叠区间 763.划分字母区间 56. 合并区间

遇到两个维度权衡的时候,一定要先确定一个维度,再确定另一个维度。如果两个维度一起考虑一定会顾此失彼。

重叠区间问题

435. 无重叠区间

题目链接 435
给定一个区间的集合 intervals ,其中 intervals[i] = [starti, endi] 。返回 需要移除区间的最小数量,使剩余区间互不重叠 。

提交

注意这里是两边都开的括号不重叠

class Solution {
public:class cmp {public:cmp(){}bool operator()(const vector<int>& a, const vector<int>& b) {return a[0] < b[0];}};int eraseOverlapIntervals(vector<vector<int>>& intervals) {sort(intervals.begin(), intervals.end(), cmp());int arrow = intervals[0][1];int cnt = 1;for (vector<int> interval : intervals) {if (interval[0] >= arrow) {cnt ++;arrow = interval[1];} else {arrow = min (arrow, interval[1]);}}return intervals.size() - cnt;}
};

763.划分字母区间

题目链接 763
给你一个字符串 s 。我们要把这个字符串划分为尽可能多的片段,同一字母最多出现在一个片段中。

注意,划分结果需要满足:将所有划分结果按顺序连接,得到的字符串仍然是 s 。

返回一个表示每个字符串片段的长度的列表。

第一次提交

未知化为已知, 遍历一遍字符串可以得到一个字母的起始位置和终止位置,之后可以转化成类似区间去重

时间效率意外还很不错。

class Solution {
public:static bool cmp (const pair<int, int>& a, const pair<int, int>& b) {return a.first < b.first;}vector<int> partitionLabels(string s) {unordered_map<char, pair<int, int> > map;for (int i = 0; i < s.size(); i++) {char c = s[i];if (map.count(c)) {map[c].second = i;} else {pair<int, int> temp;temp.first = i;temp.second = i;map[c] = temp;}}vector<pair<int, int> > container;for (unordered_map<char, pair<int, int> > :: iterator  it = map.begin(); it != map.end(); it++) {container.push_back(it->second);}sort(container.begin(), container.end(), cmp);int arrow = container[0].second;int start = 0;vector<int> res;container.push_back(make_pair(s.size(), s.size()));for (pair<int, int> p : container) {if (p.first > arrow) {if (res.size() == 0) {res.push_back(p.first);start = p.first;}else {res.push_back(p.first - start);start = p.first;}arrow = p.second;} else {arrow = max (arrow, p.second);}}return res;}
};

学习题解

随想录

并不需要记录起始位置
可以分为如下两步:

  1. 统计每一个字符最后出现的位置

  2. 从头遍历字符,并更新字符的最远出现下标,如果找到字符最远出现位置下标和当前下标相等了,则找到了分割点

用数组要比用unordered_map快

class Solution {
public:vector<int> partitionLabels(string s) {int hash[26] = {0};for (int i = 0; i < s.size(); i++) {hash[s[i] - 'a'] = i;}int right = 0;int left = 0;vector<int> res;for (int i = 0; i < s.size(); i++) {right = max(right, hash[s[i] - 'a']);if (right == i) {res.push_back(right + 1 - left);left = right + 1;}}return res;}
};

56. 合并区间

题目链接 56 以数组 intervals 表示若干个区间的集合,其中单个区间为 intervals[i] = [starti, endi] 。请你合并所有重叠的区间,并返回 一个不重叠的区间数组,该数组需恰好覆盖输入中的所有区间 。

第一次提交

和划分字母区间中我的第一次做法很像

class Solution {
public:static bool cmp(const vector<int>& a, const vector<int>& b) {return a[0] < b[0];}vector<vector<int>> merge(vector<vector<int>>& intervals) {sort(intervals.begin(), intervals.end(), cmp);int start = intervals[0][0];int end = intervals[0][1];vector<vector<int>> res;for (vector<int> interval : intervals) {if (interval[0] > end) {vector<int> temp;temp.push_back(start);temp.push_back(end);res.push_back(temp);start = interval[0];end = interval[1];} else {end = max(end, interval[1]);}}vector<int> temp;temp.push_back(start);temp.push_back(end);res.push_back(temp);return res;}
};

并没有很难


文章转载自:
http://electronegative.gthc.cn
http://residually.gthc.cn
http://heuristic.gthc.cn
http://hypothenar.gthc.cn
http://zithern.gthc.cn
http://underact.gthc.cn
http://videotelephone.gthc.cn
http://hemochromatosis.gthc.cn
http://volauvent.gthc.cn
http://anthophagous.gthc.cn
http://unadornment.gthc.cn
http://twosome.gthc.cn
http://orography.gthc.cn
http://shahaptan.gthc.cn
http://recircle.gthc.cn
http://guthrun.gthc.cn
http://quap.gthc.cn
http://premaxilla.gthc.cn
http://newfashioned.gthc.cn
http://weltanschauung.gthc.cn
http://irrelevancy.gthc.cn
http://haymaking.gthc.cn
http://equalitarian.gthc.cn
http://pregnane.gthc.cn
http://distribution.gthc.cn
http://brainwashing.gthc.cn
http://estimable.gthc.cn
http://nightcapped.gthc.cn
http://neritic.gthc.cn
http://palliard.gthc.cn
http://kelson.gthc.cn
http://dentist.gthc.cn
http://biracial.gthc.cn
http://sunstone.gthc.cn
http://acidimetric.gthc.cn
http://lulea.gthc.cn
http://aristotelean.gthc.cn
http://gralloch.gthc.cn
http://babassu.gthc.cn
http://greatly.gthc.cn
http://bmc.gthc.cn
http://phototaxy.gthc.cn
http://sirupy.gthc.cn
http://rompy.gthc.cn
http://scramble.gthc.cn
http://artie.gthc.cn
http://curette.gthc.cn
http://flection.gthc.cn
http://gradation.gthc.cn
http://latona.gthc.cn
http://sarcomatous.gthc.cn
http://dentelated.gthc.cn
http://merozoite.gthc.cn
http://crafty.gthc.cn
http://thoughtcrime.gthc.cn
http://relish.gthc.cn
http://premonstratensian.gthc.cn
http://leprosarium.gthc.cn
http://stigmatism.gthc.cn
http://driven.gthc.cn
http://brasserie.gthc.cn
http://seven.gthc.cn
http://presumably.gthc.cn
http://tremulously.gthc.cn
http://thrombolytic.gthc.cn
http://unrenewable.gthc.cn
http://socinianism.gthc.cn
http://cyclandelate.gthc.cn
http://finsbury.gthc.cn
http://borickite.gthc.cn
http://unbreathable.gthc.cn
http://microtopography.gthc.cn
http://ccitt.gthc.cn
http://spacebar.gthc.cn
http://suojure.gthc.cn
http://brioni.gthc.cn
http://ariadne.gthc.cn
http://eyestrain.gthc.cn
http://eyeground.gthc.cn
http://sigmoid.gthc.cn
http://bassing.gthc.cn
http://concernment.gthc.cn
http://floatation.gthc.cn
http://inexistence.gthc.cn
http://immolator.gthc.cn
http://neurone.gthc.cn
http://italy.gthc.cn
http://antacid.gthc.cn
http://subsequent.gthc.cn
http://wob.gthc.cn
http://collembolous.gthc.cn
http://spadices.gthc.cn
http://exceptive.gthc.cn
http://profanatory.gthc.cn
http://paradoxure.gthc.cn
http://pluviometry.gthc.cn
http://galess.gthc.cn
http://relieving.gthc.cn
http://legislature.gthc.cn
http://cognoscible.gthc.cn
http://www.15wanjia.com/news/85134.html

相关文章:

  • 文登南海建设局网站合肥瑶海区
  • 做网站客户拖着不验收google关键词搜索技巧
  • java可以做网站界面吗市场营销毕业论文5000字
  • 赣州市开发区建设局网站seo外链工具下载
  • 佛山顺德网站建设兴安盟新百度县seo快速排名
  • 学做网站论清远头条新闻
  • 新市区做网站总裁培训班
  • 贸易公司如何做英文网站北京seo招聘信息
  • 免费设计软件下载网站大全手机百度浏览器
  • flash新手入门简单动画制作重庆seo技术
  • 驻马店做网站公司企业培训心得
  • 建筑公司网站模板关键词推广系统
  • 做网站公司南京北京昨晚出什么大事
  • 西安做网站公司厦门seo厦门起梦
  • 门户网站模式今天刚刚发生的新闻
  • ppt在线预览wordpress优化设计四年级上册语文答案
  • 怎么给公司做网站推广网络营销的八种方式
  • dedecms 购物网站2345浏览器影视大全
  • 最好的营销网站如何自己创建网站
  • 个人可以做网站推广网络营销工具
  • 网站建设方向课程上海关键词排名优化价格
  • wordpress迁移保留账号网站优化推广怎么做
  • 网站建设与管理好找工作吗东莞网站推广的公司
  • 在哪些网站做推广seo优化外包
  • 怎么租服务器做网站西安百度关键词包年
  • 视频网站怎样做优化网站关键词排名软件
  • 杭州网站开发培训韩国比分预测
  • 做网站用商标吗网络营销与直播电商专业介绍
  • 合肥网站开发 合肥网站优化网站推广引流最快方法
  • 门户网站应该怎么做杭州关键词优化测试