diff --git a/problems/0763.划分字母区间.md b/problems/0763.划分字母区间.md index 41314456..4e9ec578 100644 --- a/problems/0763.划分字母区间.md +++ b/problems/0763.划分字母区间.md @@ -404,6 +404,32 @@ impl Solution { } } ``` +### C# +```csharp +public class Solution +{ + public IList PartitionLabels(string s) + { + int[] location = new int[27]; + for (int i = 0; i < s.Length; i++) + { + location[s[i] - 'a'] = i; + } + List res = new List(); + int left = 0, right = 0; + for (int i = 0; i < s.Length; i++) + { + right = Math.Max(right, location[s[i] - 'a']); + if (i == right) + { + res.Add(right - left + 1); + left = i + 1; + } + } + return res; + } +} +```