Skip to content

Commit 32a8777

Browse files
committed
Fixed handling of poorly constructed Binary Max Heaps
1 parent 22b399c commit 32a8777

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

medium/binary_tree_lca.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function binaryTreeLca(strArr) {
3333

3434
// Find LCA
3535
for (let i = 0; i < nodeAPath.length; i++) {
36-
if (nodeBPath.includes(nodeAPath[i])) {
36+
if (nodeBPath.includes(nodeAPath[i]) && nodeAPath[i] !== '#') {
3737
return Number(nodeAPath[i]);
3838
}
3939
}

0 commit comments

Comments
 (0)