mirror of
https://github.com/20kaushik02/leetcode-gulag.git
synced 2025-12-06 09:34:07 +00:00
19 lines
472 B
C++
19 lines
472 B
C++
#include <bits/stdc++.h>
|
|
using namespace std;
|
|
|
|
struct TreeNode
|
|
{
|
|
int val;
|
|
TreeNode *left;
|
|
TreeNode *right;
|
|
TreeNode() : val(0), left(nullptr), right(nullptr) {}
|
|
TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
|
|
TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
|
|
};
|
|
class Solution
|
|
{
|
|
public:
|
|
int diameterOfBinaryTree(TreeNode *root);
|
|
int height(TreeNode *subroot, int &max_dia);
|
|
bool test(TreeNode *root, int answer);
|
|
}; |