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 cb9a717

Browse files
fix(0763): 下标取 字母 - 'a' 的值,少点空间
1 parent 7c8549d commit cb9a717

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,15 @@ Java:
8888
class Solution {
8989
public List<Integer> partitionLabels(String S) {
9090
List<Integer> list = new LinkedList<>();
91-
int[] edge = new int[123];
91+
int[] edge = new int[26];
9292
char[] chars = S.toCharArray();
9393
for (int i = 0; i < chars.length; i++) {
94-
edge[chars[i] - 0] = i;
94+
edge[chars[i] - 'a'] = i;
9595
}
9696
int idx = 0;
9797
int last = -1;
9898
for (int i = 0; i < chars.length; i++) {
99-
idx = Math.max(idx,edge[chars[i] - 0]);
99+
idx = Math.max(idx,edge[chars[i] - 'a']);
100100
if (i == idx) {
101101
list.add(i - last);
102102
last = i;

0 commit comments

Comments
(0)

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