Skip to content

Commit f609530

Browse files
authored
Update README.md
1 parent 1366d3e commit f609530

File tree

1 file changed

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

1 file changed

+18
-19
lines changed

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

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -303,29 +303,28 @@ class Solution {
303303
#### C
304304

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

321-
if (ans < r - l + 1) {
322-
ans = r - l + 1;
321+
if (ans < r - l + 1) {
322+
ans = r - l + 1;
323+
}
323324
}
324-
}
325325

326-
return ans;
326+
return ans;
327327
}
328-
329328
```
330329
331330
<!-- tabs:end -->

0 commit comments

Comments
 (0)