Re: [閒聊] 每日LeetCode
104. Maximum Depth of Binary Tree
找出一棵二元樹的max depth
C# code
public class Solution {
public int MaxDepth(TreeNode node) {
if (node == null) return 0;
return 1+Math.Max(MaxDepth(node.left),MaxDepth(node.right));
}
}
捏
--
(づ′・ω・)づ
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 118.241.148.203 (日本)
※ 文章網址: https://www.ptt.cc/bbs/Marginalman/M.1676510308.A.458.html
推
02/16 09:18,
2年前
, 1F
02/16 09:18, 1F
→
02/16 09:21,
2年前
, 2F
02/16 09:21, 2F
→
02/16 09:21,
2年前
, 3F
02/16 09:21, 3F
→
02/16 09:24,
2年前
, 4F
02/16 09:24, 4F
→
02/16 11:23,
2年前
, 5F
02/16 11:23, 5F
討論串 (同標題文章)
完整討論串 (本文為第 234 之 719 篇):