当前位置:网站首页>贪心之区间问题(3)
贪心之区间问题(3)
2022-06-22 17:50:00 【Douglas_LT】
每日一题ing,今天是个medium题763. Partition Labels
class Solution {
public:
int Max(int a,int b)
{
if(a>b)
return a;
else
return b;
}
vector<int> partitionLabels(string s) {
int min=0,mark[150];
vector<int> temp;
temp.push_back(-1);
for(int i=0;i<s.length();i++)
{
mark[s[i]]=i;
}
int i=0;
while(i<s.length())
{
int flag=1,max=0;
for(int j=i+1;j<Max(mark[s[i]],max);j++)
{
if(mark[s[j]]>mark[s[i]])
{
flag=0;
if(mark[s[j]]>max)
max=mark[s[j]];
}
}
if(flag==0)
{
temp.push_back(max);
i=max+1>mark[s[i]]+1?max+1:mark[s[i]]+1;
}
if(flag==1)
{
temp.push_back(mark[s[i]]);
i=mark[s[i]]+1;
}
}
vector<int> result;
for(int i=1;i<temp.size();i++)
{
result.push_back(temp[i]-temp[i-1]);
}
return result;
}
};
边栏推荐
- 线程池:ThreadPoolExcutor源码阅读
- vs code突然无法进行代码跳转
- Modèle de langage de pré - formation, Bert, roformer Sim aussi connu sous le nom de simbertv2
- PLSQL variable assignment
- 如何更改Apple Watch上的表盘
- The Fourth Youth Life Science Forum | first round notice
- 如何在 FlowUs和Notion 等笔记软件中进行任务管理?
- JVM quick start
- Introduction to rsps2022 finalist | Dr. Yang Bai
- Getting started with database connection pooling (c3p0, Druid)
猜你喜欢

2022年R2移动式压力容器充装试题模拟考试平台操作

今天19:30 | 科普大佬说,带大家探寻AI如何激发人类的创造力

Redis中的布隆过滤器与布谷鸟过滤器,你了解多少?

Vs Code suddenly fails to jump

2022 R2 mobile pressure vessel filling test question simulation test platform operation

Game NFT Market: opensea's most easily cut cake

2022重庆幼教产业展览会|高科技玩具益智解压玩具博览会

AUTOCAD——五种标注快捷键
Set of redis data structure

c# sqlsugar,hisql,freesql orm框架全方位性能测试对比之sqlserver
随机推荐
游戏NFT市场:OpenSea最易被切下的蛋糕
Plan and change of continuous repair
How MySQL deletes a column in a database table
巴比特 | 元宇宙每日必读:传腾讯成立XR部门,元宇宙板块再次上涨,多家券商发报告关注虚拟人的投资机会...
3GPP 5G R17标准冻结,RedCap作为重要特性值得关注!
Robotframework installation tutorial
Explain the startup process of opengauss multithreading architecture in detail
直播预告 | 12位一作华人学者开启 ICLR 2022
Jenkins configuration project integration pin notification
缓存3种方式及原理
How can I automatically make an appointment to make a new debt? Is it convenient and safe to make an appointment to make a new bond
静态链表(一)
plsql变量赋值问题
sqlserver保存时遇到这个页面怎么回事啊
阿里云过户找不到账号安全组ID问题
wpa_ CLI parameter description
链表4- 21 合并两个有序链表
jsp连接MySQL总出错
Golang implements redis (10): local atomic transactions
函数的导数与微分的关系