File tree Expand file tree Collapse file tree 1 file changed +16
-16
lines changed
solution/0000-0099/0003.Longest Substring Without Repeating Characters Expand file tree Collapse file tree 1 file changed +16
-16
lines changed Original file line number Diff line number Diff line change 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}
You can’t perform that action at this time.
0 commit comments