Skip to content

Commit 63dd517

Browse files
authored
Create main.cpp
1 parent 5b7e0c2 commit 63dd517

File tree

1 file changed

+13
-0
lines changed
  • 17 - Binary Tree Data Structure Problems/02 - Height of Binary Tree

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution{
2+
public:
3+
//Function to find the height of a binary tree.
4+
int height(struct Node* node){
5+
// base case
6+
if(node == NULL) return 0;
7+
8+
int left = height(node -> left);
9+
int right = height(node -> right);
10+
11+
return max(left, right) + 1;
12+
}
13+
};

0 commit comments

Comments
 (0)