@@ -22,32 +22,32 @@ var pseudoPalindromicPaths = function(root) {
22
22
23
23
const removeNum = ( num , hashSet ) => {
24
24
hashSet [ num ] = hashSet [ num ] - 1 ;
25
- if ( hashSet [ num ] === 0 ) delete hashSet [ num ] ;
25
+ if ( hashSet [ num ] === 0 ) delete hashSet [ num ] ;
26
26
}
27
27
28
28
const isPalindrome = ( hashSet ) => {
29
29
30
30
let oddOccurances = 0 ;
31
31
32
- for ( const key in hashSet ) {
33
- if ( hashSet [ key ] % 2 ) oddOccurances ++ ;
32
+ for ( const key in hashSet ) {
33
+ if ( hashSet [ key ] % 2 ) oddOccurances ++ ;
34
34
}
35
35
36
36
return oddOccurances < 2 ;
37
37
}
38
38
39
39
const dfs = ( node , hashSet ) => {
40
- if ( ! node . left && ! node . right && isPalindrome ( hashSet ) ) return 1 ;
41
- if ( ! node . left && ! node . right ) return 0 ;
40
+ if ( ! node . left && ! node . right && isPalindrome ( hashSet ) ) return 1 ;
41
+ if ( ! node . left && ! node . right ) return 0 ;
42
42
43
43
let total = 0 ;
44
- if ( node . left ) {
44
+ if ( node . left ) {
45
45
addNum ( node . left . val , hashSet ) ;
46
46
total += dfs ( node . left , hashSet ) ;
47
47
removeNum ( node . left . val , hashSet ) ;
48
48
}
49
49
50
- if ( node . right ) {
50
+ if ( node . right ) {
51
51
addNum ( node . right . val , hashSet ) ;
52
52
total += dfs ( node . right , hashSet ) ;
53
53
removeNum ( node . right . val , hashSet ) ;
@@ -56,6 +56,6 @@ var pseudoPalindromicPaths = function(root) {
56
56
return total ;
57
57
}
58
58
59
- return dfs ( root , { [ root . val ] : 1 } ) ;
59
+ return dfs ( root , { [ root . val ] : 1 } \ ) ;
60
60
61
61
} ;
0 commit comments