Re: [閒聊] 每日leetcode已回收
※ 引述《sustainer123 (caster )》之銘言:
: https://leetcode.com/problems/sum-of-left-leaves
: 404. Sum of Left Leaves
: 求左子葉和
C# code
public class Solution {
public int SumOfLeftLeaves(TreeNode root, bool isLeft = false) {
if (root == null) return 0;
if (isLeft && root.left == null && root.right == null) return root.val
;
return SumOfLeftLeaves(root.left, true) + SumOfLeftLeaves(root.right,
false);
}
}
窩只寫簡單 中級偶爾 HARD跳過==
--
(づ′・ω・)づ
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 49.158.160.52 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/Marginalman/M.1713084427.A.1F8.html
※ 編輯: SecondRun (49.158.160.52 臺灣), 04/14/2024 16:52:14
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 117 之 1548 篇):