C++简洁代码/递归一行:
class Solution { public: int TreeDepth(TreeNode* pRoot) { return !pRoot ? 0 : max(TreeDepth(pRoot->left), TreeDepth(pRoot->right)) + 1; } };
C++简洁代码/递归一行:
class Solution { public: int TreeDepth(TreeNode* pRoot) { return !pRoot ? 0 : max(TreeDepth(pRoot->left), TreeDepth(pRoot->right)) + 1; } };