Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 20f331f

Browse files
committed
Update 0763.划分字符区间,添加C#
1 parent 6add8c3 commit 20f331f

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

‎problems/0763.划分字母区间.md‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,32 @@ impl Solution {
404404
}
405405
}
406406
```
407+
### C#
408+
```csharp
409+
public class Solution
410+
{
411+
public IList<int> PartitionLabels(string s)
412+
{
413+
int[] location = new int[27];
414+
for (int i = 0; i < s.Length; i++)
415+
{
416+
location[s[i] - 'a'] = i;
417+
}
418+
List<int> res = new List<int>();
419+
int left = 0, right = 0;
420+
for (int i = 0; i < s.Length; i++)
421+
{
422+
right = Math.Max(right, location[s[i] - 'a']);
423+
if (i == right)
424+
{
425+
res.Add(right - left + 1);
426+
left = i + 1;
427+
}
428+
}
429+
return res;
430+
}
431+
}
432+
```
407433

408434
<p align="center">
409435
<a href="https://programmercarl.com/other/kstar.html" target="_blank">

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /