File tree Expand file tree Collapse file tree 1 file changed +18
-19
lines changed
solution/0000-0099/0003.Longest Substring Without Repeating Characters Expand file tree Collapse file tree 1 file changed +18
-19
lines changed Original file line number Diff line number Diff line change @@ -303,29 +303,28 @@ class Solution {
303
303
#### C
304
304
305
305
``` 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
+ }
320
320
321
- if (ans < r - l + 1) {
322
- ans = r - l + 1;
321
+ if (ans < r - l + 1) {
322
+ ans = r - l + 1;
323
+ }
323
324
}
324
- }
325
325
326
- return ans;
326
+ return ans;
327
327
}
328
-
329
328
```
330
329
331
330
<!-- tabs:end -->
You can’t perform that action at this time.
0 commit comments