Posts Height of Binary Tree (geeksforgeeks - SDE Sheet)
Post
Cancel

Height of Binary Tree (geeksforgeeks - SDE Sheet)

PROBLEM DESCRIPTION

Given a binary tree, find its height.

geeksforgeeks

SOLUTION

1
2
3
4
5
6
7
8
class Solution {

    int height(Node node)
    {
        return node == null ? 0 : 1 + Math.max(height(node.left), height(node.right));
    }

}
This post is licensed under CC BY 4.0 by the author.