indrakishore / Developers-Community

Hactoberfest-2024
MIT License
13 stars 122 forks source link

Maximum Depth of Binary Tree #55

Open Rajesh-1234567 opened 1 month ago

Rajesh-1234567 commented 1 month ago

Given the root of a binary tree, write an algorithm to find its maximum depth.

Input:

Output:

Constraints:

Example 1:

Input:
    3
   / \
  9  20
     /  \
    15   7

Output: 3

Explanation: The longest path is root -> 20 -> 7, which has 3 nodes.

Example 2:

Input:
    1
     \
      2

Output: 2

Explanation: The tree has a maximum depth of 2, since the longest path is root -> 2.

Example 3:

Input: None (Empty tree)

Output: 0

Explanation: The tree is empty, so the maximum depth is 0.

Hey @indrakishore ! Kindly assign me this task.

shrutipuskar commented 1 month ago

plz assign this task to me and also add hactoberfest tag........