543. Diameter of Binary Tree

1.問題

  • 計算diameter: 任意兩node間最長的path

2.想法

  • 參考104. Maximum Depth of Binary Tree

  • 回傳值為 max(left path, right path) +1

  • res = max(res, left path + right path)

3.程式碼

Last updated