binary_tree1 [C++][leetcode] Diameter of Binary Tree :: seoftware 소스코드 /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ class Solution { int max; void maxDepth(TreeNode* root) { if (root == NULL) { return; } max = std::max(max, height(root->left) + height(root->right)); maxDepth(root->left); maxDepth(root->right); } int height(TreeNode* ro.. 2020. 4. 12. 이전 1 다음