Definition at line 15 of file main.cpp.
◆ maxDepth()
| int Solution::maxDepth |
( |
TreeNode * |
root | ) |
|
|
inline |
Definition at line 18 of file main.cpp.
19 {
20 if (!root)
21 return 0;
22 queue<pair<TreeNode*, int>> q;
23 q.push({root, 1});
24 int level = 0;
25 while (!q.empty())
26 {
28 level = max(level, q.front().second);
29 q.pop();
30
32 q.push({t->
left, level + 1});
34 q.push({t->
right, level + 1});
35 }
36 return level;
37 }
References TreeNode::left, and TreeNode::right.
Referenced by main().
The documentation for this class was generated from the following file: