File tree 1 file changed +18
-18
lines changed
1 file changed +18
-18
lines changed Original file line number Diff line number Diff line change 3
3
* @param {number[] } bobValues
4
4
* @return {number }
5
5
*/
6
- var stoneGameVI = function ( aliceValues , bobValues ) {
7
- let data = [ ]
8
- const length = aliceValues . length
9
- for ( let i = 0 ; i < length ; i ++ ) {
10
- data . push ( [ aliceValues [ i ] + bobValues [ i ] , aliceValues [ i ] , bobValues [ i ] ] )
11
- }
12
- data . sort ( ( a , b ) => a [ 0 ] - b [ 0 ] )
13
- data = data . reverse ( )
6
+ const stoneGameVI = function ( aliceValues , bobValues ) {
7
+ let data = [ ]
8
+ const length = aliceValues . length
9
+ for ( let i = 0 ; i < length ; i ++ ) {
10
+ data . push ( [ aliceValues [ i ] + bobValues [ i ] , aliceValues [ i ] , bobValues [ i ] ] )
11
+ }
12
+ data . sort ( ( a , b ) => a [ 0 ] - b [ 0 ] )
13
+ data = data . reverse ( )
14
14
15
- let aScore = 0
16
- let bScore = 0
17
- for ( let i = 0 ; i < length ; i ++ ) {
18
- if ( i % 2 == 0 ) aScore += data [ i ] [ 1 ]
19
- else bScore += data [ i ] [ 2 ]
20
- }
15
+ let aScore = 0
16
+ let bScore = 0
17
+ for ( let i = 0 ; i < length ; i ++ ) {
18
+ if ( i % 2 == 0 ) aScore += data [ i ] [ 1 ]
19
+ else bScore += data [ i ] [ 2 ]
20
+ }
21
21
22
- if ( aScore > bScore ) return 1
23
- else if ( aScore == bScore ) return 0
24
- else return - 1
25
- } ;
22
+ if ( aScore > bScore ) return 1
23
+ else if ( aScore == bScore ) return 0
24
+ else return - 1
25
+ }
You can’t perform that action at this time.
0 commit comments