[LeetCode] Balanced Binary Tree in Objective C

typedef struct {
int value;
struct TreeNode *left;
struct TreeNode *right;
} TreeNode;
- (BOOL)isBalanced:(TreeNode *)node
if (!node) return true;
return (abs(maximumDepth(node.left)-maximumDepth(node.right)) <=1
&& isBalanced(node.left)
&& isBalanced(node.right);
- (int)maximumDepth:(TreeNode *)node
if (!node) return 0;
return MAX(maximumDepth(node.left), maximumDepth(node.right)) + 1;
Like what you read? Give Eddie a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.