112. Path Sum


https://leetcode.com/problems/path-sum/
terminal case 1: root == null, 本身就 null, 一定不對
terminal case 2: root.left == null, root.right == null, 代表到 leaf 了, 所以此時要 check 結果是否正確 (sum == targetSum or 如果是用減的, chack root.val == targetSum
其他左右遍歷
my version
or
better version
Last updated
Was this helpful?