Root to path sum tree (both iterative and recursive)
Sigiloso
def hasPathSum(self, root: Optional[TreeNode], targetSum: int) -> bool: if not root: return False elif not root.left and not root.right: return targetSum == root.val else: return self.hasPathSum(root.left, targetSum - root.val) or self.hasPathSum(root.right, targetSum - root.val)