java.lang.Object
g0101_0200.s0104_maximum_depth_of_binary_tree.Solution

public class Solution extends Object
104 - Maximum Depth of Binary Tree.<p>Easy</p> <p>Given the <code>root</code> of a binary tree, return <em>its maximum depth</em>.</p> <p>A binary tree&rsquo;s <strong>maximum depth</strong> is the number of nodes along the longest path from the root node down to the farthest leaf node.</p> <p><strong>Example 1:</strong></p> <p><img src="https://assets.leetcode.com/uploads/2020/11/26/tmp-tree.jpg" alt="" /></p> <p><strong>Input:</strong> root = [3,9,20,null,null,15,7]</p> <p><strong>Output:</strong> 3</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> root = [1,null,2]</p> <p><strong>Output:</strong> 2</p> <p><strong>Example 3:</strong></p> <p><strong>Input:</strong> root = []</p> <p><strong>Output:</strong> 0</p> <p><strong>Example 4:</strong></p> <p><strong>Input:</strong> root = [0]</p> <p><strong>Output:</strong> 1</p> <p><strong>Constraints:</strong></p> <ul> <li>The number of nodes in the tree is in the range <code>[0, 10<sup>4</sup>]</code>.</li> <li><code>-100 <= Node.val <= 100</code></li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • maxDepth

      public int maxDepth(TreeNode root)