File tree Expand file tree Collapse file tree 2 files changed +5
-6
lines changed
longest-substring-without-repeating-characters Expand file tree Collapse file tree 2 files changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -11,12 +11,11 @@ var lengthOfLongestSubstring = function (s) {
1111 const map = new Map ( ) ;
1212 let answer = 0 ;
1313 let start = 0 ;
14- let end = 0 ;
14+
1515 for ( let i = 0 ; i < s . length ; i ++ ) {
1616 if ( map . has ( s [ i ] ) ) start = Math . max ( map . get ( s [ i ] ) + 1 , start ) ;
1717 map . set ( s [ i ] , i ) ;
18- end += 1 ;
19- answer = Math . max ( answer , end - start ) ;
18+ answer = Math . max ( answer , i - start + 1 ) ;
2019 }
2120
2221 return answer ;
Original file line number Diff line number Diff line change 1010var reverseList = function ( head ) {
1111 let answer = null ;
1212
13- const search = ( target ) => {
13+ const buildReverseList = ( target ) => {
1414 if ( target === null ) return ;
1515
1616 const node = new ListNode ( target . val , answer ) ;
1717 answer = node ;
1818
19- search ( target . next ) ;
19+ buildReverseList ( target . next ) ;
2020 } ;
2121
22- search ( head ) ;
22+ buildReverseList ( head ) ;
2323
2424 return answer ;
2525} ;
You can’t perform that action at this time.
0 commit comments