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 {
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 -->
You can’t perform that action at this time.
0 commit comments