当前位置:网站首页>贪心之区间问题(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;
}
};
边栏推荐
- Traditional image -- LBP feature
- How MySQL deletes a column in a database table
- Oculus学习笔记之控制器输入初步(一)
- Mise en œuvre de redis par golang (10): transactions atomiques locales
- 最长公共子序列
- 第四届青年生命科学论坛 | 第一轮通知
- Centeros install mangodb
- Static linked list (I)
- At 19:30 today, the science popularization leader said that he would take you to explore how AI can stimulate human creativity
- How much do you know about the bloom filter and cuckoo filter in redis?
猜你喜欢

RobotFramework 安装教程

RSPS2022 Finalist | Dr. Yang Bai 简介

链表4- 21 合并两个有序链表

5G 短消息解决方案

零基础学编程/学逆向/过检测(frida实战)

JSP connection MySQL total error

在循环中动态改变标签元素的样式
![[learn shell programming easily]-4. The difference between single quotation marks and double quotation marks, the operation of integer values, the definition of arrays in the shell and the detailed us](/img/88/5d8800e5723b4e34e832271d139eaa.png)
[learn shell programming easily]-4. The difference between single quotation marks and double quotation marks, the operation of integer values, the definition of arrays in the shell and the detailed us

UE4_ Ue5 make 3dui follow the camera orientation (attached works)

Activity跳转到Fragment的方法(Intent)
随机推荐
牛客网:判断是否为回文字符串
SystemVerilog (12) - $unit declaration space
C sqlsugar, hisql, FreeSQL ORM framework omni-directional performance test comparison sqlserver
如何在 FlowUs和Notion 等笔记软件中进行任务管理?
零基础学编程/学逆向/过检测(frida实战)
每天5分钟玩转Kubernetes | Dashboard典型使用场景
2022 operation of simulated examination platform for examination question bank of welder (elementary) special operation certificate
IPLOOK 5GC与亚信国际CHF(计费功能)对接成功
Golang实现基于Redis的可靠延迟队列
炒股开户选择哪个券商公司是最安全最好呢
在循环中动态改变标签元素的样式
预约打新债哪个券商公司开户好,开账户是更安全呢
Zero basic programming / reverse learning / over detection (Frida practice)
新人报道的笔记
centerOS 安装mangodb
postman学习
Redis usage scenario sharing (project practice)
Complete the sqlsession interface and implementation classes
plsql变量赋值问题
Play typical usage scenarios of kubernetes | dashboard for 5 minutes every day