124-Binary-Tree-Maximum-Path-Sum
Sat 17 May 2025
https://leetcode.com/problems/binary-tree-maximum-path-sum
import pyutil as pyu
pyu.get_local_pyinfo()
print(pyu.ps2("python-dotenv"))
from typing import List
class Solution:
def maxPathSum(self, root: Optional[TreeNode]) -> int:
ans = -math.inf
def maxPathSumDownFrom(root: Optional[TreeNode]) -> int:
nonlocal ans
if not root:
return 0
l = max(0, maxPathSumDownFrom(root.left …Category: leetcode
Read More