Skip to content

Commit 377d9dd

Browse files
authored
Update README_EN.md
1 parent f609530 commit 377d9dd

File tree

1 file changed

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

1 file changed

+18
-20
lines changed

solution/0000-0099/0003.Longest Substring Without Repeating Characters/README_EN.md

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -301,30 +301,28 @@ class Solution {
301301
#### C
302302

303303
```c
304+
int lengthOfLongestSubstring(char* s) {
305+
int freq[256] = {0};
306+
int l = 0, r = 0;
307+
int ans = 0;
308+
int len = strlen(s);
309+
310+
for (r = 0; r < len; r++) {
311+
char c = s[r];
312+
freq[(unsigned char) c]++;
313+
314+
while (freq[(unsigned char) c] > 1) {
315+
freq[(unsigned char) s[l]]--;
316+
l++;
317+
}
304318

305-
int lengthOfLongestSubstring(char *s) {
306-
int freq[256] = {0};
307-
int l = 0, r = 0;
308-
int ans = 0;
309-
int len = strlen(s);
310-
311-
for (r = 0; r < len; r++) {
312-
char c = s[r];
313-
freq[(unsigned char)c]++;
314-
315-
while (freq[(unsigned char)c] > 1) {
316-
freq[(unsigned char)s[l]]--;
317-
l++;
318-
}
319-
320-
if (ans < r - l + 1) {
321-
ans = r - l + 1;
319+
if (ans < r - l + 1) {
320+
ans = r - l + 1;
321+
}
322322
}
323-
}
324323

325-
return ans;
324+
return ans;
326325
}
327-
328326
```
329327
330328
<!-- tabs:end -->

0 commit comments

Comments
 (0)