[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.102
BTC 66132.49
ETH 1926.32
USDT 1.00
SBD 0.39