763. 划分字母区间
public class Solution {
public IList<int> PartitionLabels(string s) {
IList<int> result = new List<int>();
int[] hash = new int[26];
for(int i = 0; i < s.Length;i++)
{
hash[s[i]-'a'] = i;
}
int left = 0;
int right = 0;
for(int i = 0;i < s.Length;i++)
{
right= right > hash[s[i]-'a'] ? right : hash[s[i]-'a'];
if(i == right)
{
result.Add(right-left+1);
left=i+1;
}
}
return result;
}
}