[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.05
TRX 0.33
JST 0.080
BTC 63435.26
ETH 1684.80
USDT 1.00
SBD 0.41