A string S of lowercase letters is given. We want to partition this string into as many parts as possible so that each letter appears in at most one part, and return a list of integers representing the size of these parts. Example 1: Input: S = "abab…
public class Solution { public IList<int> PartitionLabels(string S) { var dic = new Dictionary<char, int[]>(); //记录每一个字符的第一次出现位置,和最后一次出现位置 ; i < S.Length; i++) { if (!dic.ContainsKey(S[i])) { dic.Add(S[i], ] { i, i }); } else { dic[S[i]][]…
int[] lastShow = new int[26]; var list = new LinkedList<Integer>(); for (int i = 0; i < s.length(); i++) { lastShow[s.charAt(i) - 'a'] = i; } int end = lastShow[s.charAt(0) - 'a']; int count = 0; for (int i = 0; i < s.length(); i++) { if (i ==…