Javascript Code
Javascript Code
constructor(val) {
this.val = val;
this.left = null;
this.right = null;
}
}
function canReachLeaf(root) {
if (root == null || root.val == 0) {
return false;
}
if (root.left == null && root.right == null) {
return true;
}
if (canReachLeaf(root.left)) {
return true;
}
if (canReachLeaf(root.right)) {
return true;
}
return false;
}