File tree 3 files changed +22
-2
lines changed
3 files changed +22
-2
lines changed Original file line number Diff line number Diff line change 370
370
| 56| [ Merge Intervals] ( https://leetcode.com/problems/merge-intervals/ ) | | Hard|
371
371
| 55| [ Jump Game] ( https://leetcode.com/problems/jump-game/ ) | | Medium|
372
372
| 54| [ Spiral Matrix] ( https://leetcode.com/problems/spiral-matrix/ ) | | Medium|
373
- | 53| [ Maximum Subarray] ( https://leetcode.com/problems/maximum-subarray/ ) | | Medium|
373
+ | 53| [ Maximum Subarray] ( https://leetcode.com/problems/maximum-subarray/ ) | [ js ] ( ./algorithms/maximumSubarray/maximumSubarray.js ) | Medium|
374
374
| 52| [ N-Queens II] ( https://leetcode.com/problems/n-queens-ii/ ) | | Hard|
375
375
| 51| [ N-Queens] ( https://leetcode.com/problems/n-queens/ ) | | Hard|
376
376
| 50| [ "Pow(x, n)"] ( https://leetcode.com/problems/powx-n/ ) | | Medium|
416
416
| 10| [ Regular Expression Matching] ( https://leetcode.com/problems/regular-expression-matching/ ) | | Hard|
417
417
| 9| [ Palindrome Number] ( https://leetcode.com/problems/palindrome-number/ ) | | Easy|
418
418
| 8| [ String to Integer (atoi)] ( https://leetcode.com/problems/string-to-integer-atoi/ ) | | Easy|
419
- | 7| [ Reverse Integer] ( https://leetcode.com/problems/reverse-integer/ ) | | Easy|
419
+ | 7| [ Reverse Integer] ( https://leetcode.com/problems/reverse-integer/ ) | [ js ] ( ./algorithms/reverseInteger/reverseInteger.js ) | Easy|
420
420
| 6| [ ZigZag Conversion] ( https://leetcode.com/problems/zigzag-conversion/ ) | | Easy|
421
421
| 5| [ Longest Palindromic Substring] ( https://leetcode.com/problems/longest-palindromic-substring/ ) | | Medium|
422
422
| 4| [ Median of Two Sorted Arrays] ( https://leetcode.com/problems/median-of-two-sorted-arrays/ ) | | Hard|
Original file line number Diff line number Diff line change
1
+ var maxSubArray = function ( nums ) {
2
+ // 初始值为0,最大值为第一个无素。
3
+ let pre = 0 , maxAns = nums [ 0 ] ;
4
+ nums . forEach ( ( x ) => {
5
+ // 前一个元素加到当前元素上,取较大值
6
+ pre = Math . max ( pre + x , x ) ;
7
+ // 取结果的最大值
8
+ maxAns = Math . max ( maxAns , pre ) ;
9
+ console . log ( pre , maxAns )
10
+ } ) ;
11
+ return maxAns ;
12
+ } ;
Original file line number Diff line number Diff line change
1
+ var reverse = function ( x ) {
2
+ let result = 0 ;
3
+ while ( x !== 0 ) {
4
+ result = result * 10 + x % 10 ;
5
+ x = ( x / 10 ) | 0 ;
6
+ }
7
+ return ( result | 0 ) === result ? result : 0 ;
8
+ } ;
You can’t perform that action at this time.
0 commit comments