From 0538aa168f3e6abe600a95dbdf2ed8eec13944eb Mon Sep 17 00:00:00 2001 From: Gaurav Gupta Date: Fri, 31 Oct 2025 19:10:20 +0530 Subject: [PATCH] Maximum Depth of Binary Tree --- Maximum Depth of Binary Tree | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 Maximum Depth of Binary Tree diff --git a/Maximum Depth of Binary Tree b/Maximum Depth of Binary Tree new file mode 100644 index 0000000..d806bb0 --- /dev/null +++ b/Maximum Depth of Binary Tree @@ -0,0 +1,9 @@ +class Solution { +public: + int maxDepth(TreeNode* root) { + if(!root) return 0; + int maxLeft = maxDepth(root->left); + int maxRight = maxDepth(root->right); + return max(maxLeft, maxRight)+1; + } +};