0543_diameter-of-binary-tree

command
v0.0.0-...-60194e6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 9, 2020 License: Unlicense Imports: 0 Imported by: 0

README

0543_diameter-of-binary-tree

基于二叉树的后序遍历(post-order traversal, 相对的有pre-order, in-order).

对于每个subtree, 我们需要返回两个值:

  • subtree的深度maxDepth
  • 符合题意的答案maxDiameter
    • maxDiameter是以下三个值的最大值:
      • 左右两边深度的和+2(一边没有child就要-1)
      • 左边的subtree的maxDiameter
      • 左边的subtree的maxDiameter

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL