[LeetCode] Maximum Depth of Binary Tree in Objective C

in programming •  8 years ago 

LeetCode: Maximum Depth of Binary Tree in Objective C

typedef struct {
    int value;
    struct TreeNode *left;
    struct TreeNode *right;
 } TreeNode;

- (int)maximumDepth:(TreeNode *)node
{
    if (!node) return 0;
    return MAX(maximumDepth(node.left), maximumDepth(node.right)) + 1;
}
Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!