#include "stdbool.h" #define NULL ((void *)0) //Definition for a binary tree node. struct TreeNode { int val; struct TreeNode *left; struct TreeNode *right; }; //深度优先 int maxDepth(struct TreeNode* root){ if(root == NULL) return 0; else return fmax(maxDepth(root->left), maxDepth(root->right))+1; }
每日LeetCode - 104. 二叉树的最大深度(C语言)
原文:https://www.cnblogs.com/vicky2021/p/14810036.html