[LeetCode] Maximum Depth of Binary Tree in Objective C

in #programming9 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;
}

Coin Marketplace

STEEM 0.04
TRX 0.33
JST 0.101
BTC 66375.85
ETH 1932.17
USDT 1.00
SBD 0.38