Movatterモバイル変換


[0]ホーム

URL:


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

Commitea36b7f

Browse files
authored
Partition Labels
1 parent09b2527 commitea36b7f

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

‎763. Partition Labels/README.md‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#Solution
2+
```
3+
class Solution:
4+
def partitionLabels(self, S):
5+
i = 0
6+
last = 0
7+
out = []
8+
while len(S) > 0:
9+
index = len(S) - 1 - S[::-1].index(S[i])
10+
if last < index:
11+
last = index
12+
if i == last:
13+
out.append(last + 1)
14+
if i == len(S) - 1:
15+
break
16+
S = S[i + 1:]
17+
last = 0
18+
i = 0
19+
else:
20+
i += 1
21+
return out
22+
```

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp