@@ -21,8 +21,8 @@ var isEvenOddTree = function(root) {
21
21
22
22
for ( let i = 0 ; i < arr . length ; i ++ ) {
23
23
const currElement = arr [ i ] ;
24
- const nextElement = ( arr [ i + 1 ] !== undefined && arr [ i + 1 ] ) || Infinity ;
25
- if ( currElement >= nextElement || currElement % 2 === 0 ) return false ;
24
+ const nextElement = ( arr [ i + 1 ] !== undefined && arr [ i + 1 ] ) || Infinity ;
25
+ if ( currElement >= nextElement || currElement % 2 === 0 ) return false ;
26
26
}
27
27
28
28
return true ;
@@ -33,8 +33,8 @@ var isEvenOddTree = function(root) {
33
33
34
34
for ( let i = 0 ; i < arr . length ; i ++ ) {
35
35
const currElement = arr [ i ] ;
36
- const nextElement = ( arr [ i + 1 ] !== undefined && arr [ i + 1 ] ) || - Infinity ;
37
- if ( currElement <= nextElement || currElement % 2 === 1 ) return false ;
36
+ const nextElement = ( arr [ i + 1 ] !== undefined && arr [ i + 1 ] ) || - Infinity ;
37
+ if ( currElement <= nextElement || currElement % 2 === 1 ) return false ;
38
38
}
39
39
40
40
return true ;
@@ -55,12 +55,12 @@ var isEvenOddTree = function(root) {
55
55
const node = element [ 0 ] ;
56
56
levelArr . push ( node . val ) ;
57
57
58
- node . left && q . enqueue ( [ node . left , level + 1 ] ) ;
59
- node . right && q . enqueue ( [ node . right , level + 1 ] ) ;
58
+ node . left && q . enqueue ( [ node . left , level + 1 ] ) ;
59
+ node . right && q . enqueue ( [ node . right , level + 1 ] ) ;
60
60
}
61
61
62
- if ( level % 2 === 0 && ! isStricklyIncreasingAndOdd ( levelArr ) ) return false ;
63
- if ( level % 2 === 1 && ! isStricklyDecreasingAndEven ( levelArr ) ) return false ;
62
+ if ( level % 2 === 0 && ! isStricklyIncreasingAndOdd ( levelArr ) ) return false ;
63
+ if ( level % 2 === 1 && ! isStricklyDecreasingAndEven ( levelArr ) ) return false ;
64
64
}
65
65
66
66
return true ;
0 commit comments