Skip to content

Commit 2ea31ec

Browse files
authoredOct 13, 2024
Adjusted Spacing
1 parent c02c0d7 commit 2ea31ec

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed
 

‎javascript/1457-pseudo-palindromic-paths-in-a-binary-tree.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -22,32 +22,32 @@ var pseudoPalindromicPaths = function(root) {
2222

2323
const removeNum = (num, hashSet) => {
2424
hashSet[num] = hashSet[num] - 1;
25-
if(hashSet[num] === 0) delete hashSet[num];
25+
if (hashSet[num] === 0) delete hashSet[num];
2626
}
2727

2828
const isPalindrome = (hashSet) => {
2929

3030
let oddOccurances = 0;
3131

32-
for(const key in hashSet) {
33-
if(hashSet[key] % 2) oddOccurances++;
32+
for (const key in hashSet) {
33+
if (hashSet[key] % 2) oddOccurances++;
3434
}
3535

3636
return oddOccurances < 2;
3737
}
3838

3939
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;
4242

4343
let total = 0;
44-
if(node.left) {
44+
if (node.left) {
4545
addNum(node.left.val, hashSet);
4646
total += dfs(node.left, hashSet);
4747
removeNum(node.left.val, hashSet);
4848
}
4949

50-
if(node.right) {
50+
if (node.right) {
5151
addNum(node.right.val, hashSet);
5252
total += dfs(node.right, hashSet);
5353
removeNum(node.right.val, hashSet);
@@ -56,6 +56,6 @@ var pseudoPalindromicPaths = function(root) {
5656
return total;
5757
}
5858

59-
return dfs(root, {[root.val]: 1} );
59+
return dfs(root, {[root.val]: 1} \);
6060

6161
};

0 commit comments

Comments
 (0)
Please sign in to comment.