Skip to content

Instantly share code, notes, and snippets.

@ahmedfahmy94
Created August 18, 2021 11:23
Show Gist options
  • Save ahmedfahmy94/98ecffc7397b6f523c39beed91944cd3 to your computer and use it in GitHub Desktop.
Save ahmedfahmy94/98ecffc7397b6f523c39beed91944cd3 to your computer and use it in GitHub Desktop.
Binary Tree Depth
Given a binary tree, find its maximum depth.
The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.
Note: A leaf is a node with no children
3
/ \
9 20
/ \
15 7
/**
* Definition for a binary tree node.
* function TreeNode(val) {
* this.val = val;
* this.left = this.right = null;
* }
*/
/**
* @param {TreeNode} root
* @return {number}
*/
var maxDepth = function(root) {
//implement
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment