class Solution {
public:interaseOverlapIntervals(vector<vector<int>>& intervals){int result =0;sort(intervals.begin(), intervals.end(),[](vector<int>& a, vector<int>& b){return(a[0]== b[0])? a[1]< b[1]: a[0]< b[0];});int r = intervals[0][0]-1;for(vector<int> p : intervals){// 没有重合,移动右区间if(r <= p[0]){
r = p[1];}// 重合时取小的右区间else{
r =min(p[1], r);
result++;}}return result;}};
class Solution {
public:
vector<int>partitionLabels(string s){
vector<vector<int>>positions(26, vector<int>(2,-1));for(int i =0; i < s.length(); i++){if(positions[s[i]-'a'][0]==-1){
positions[s[i]-'a'][0]= i;
positions[s[i]-'a'][1]= i;}else{
positions[s[i]-'a'][1]= i;}}sort(positions.begin(), positions.end(),[](vector<int>& a, vector<int>& b){return a[0]< b[0];});int l =0;int r =-1;
vector<int> result;for(int i =0; i <26; i++){if(positions[i][0]==-1)continue;if(r < positions[i][0]&& r !=-1){
result.push_back(r-l+1);
r = positions[i][1];
l = positions[i][0];}else{
r =max(r, positions[i][1]);}}
result.push_back(r-l+1);return result;}};