Skip to content

Commit 6053870

Browse files
authored
Update Solution.c
1 parent 377d9dd commit 6053870

File tree

1 file changed

+16
-16
lines changed
  • solution/0000-0099/0003.Longest Substring Without Repeating Characters

1 file changed

+16
-16
lines changed
Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
int lengthOfLongestSubstring(char *s) {
2-
int freq[256] = {0};
3-
int l = 0, r = 0;
4-
int ans = 0;
5-
int len = strlen(s);
1+
int lengthOfLongestSubstring(char* s) {
2+
int freq[256] = {0};
3+
int l = 0, r = 0;
4+
int ans = 0;
5+
int len = strlen(s);
66

7-
for (r = 0; r < len; r++) {
8-
char c = s[r];
9-
freq[(unsigned char)c]++;
7+
for (r = 0; r < len; r++) {
8+
char c = s[r];
9+
freq[(unsigned char) c]++;
1010

11-
while (freq[(unsigned char)c] > 1) {
12-
freq[(unsigned char)s[l]]--;
13-
l++;
14-
}
11+
while (freq[(unsigned char) c] > 1) {
12+
freq[(unsigned char) s[l]]--;
13+
l++;
14+
}
1515

16-
if (ans < r - l + 1) {
17-
ans = r - l + 1;
16+
if (ans < r - l + 1) {
17+
ans = r - l + 1;
18+
}
1819
}
19-
}
2020

21-
return ans;
21+
return ans;
2222
}

0 commit comments

Comments
 (0)