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 );
6
6
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 ]++ ;
10
10
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
+ }
15
15
16
- if (ans < r - l + 1 ) {
17
- ans = r - l + 1 ;
16
+ if (ans < r - l + 1 ) {
17
+ ans = r - l + 1 ;
18
+ }
18
19
}
19
- }
20
20
21
- return ans ;
21
+ return ans ;
22
22
}
You can’t perform that action at this time.
0 commit comments