#include <bits/stdc++.h>
using namespace std;
struct TreeNode {
int val;
TreeNode *left, *right;
};
void dfsGetDepth(TreeNode *root, int &x) {
if (!root) return;
queue<TreeNode*> q;
q.push(root);
while (!q.empty()) {
int n = q.size();
for (int i=0; i<n; ++i) {
auto f=q.front();q.pop();
if (f->left) q.push(f->left);
if (f->right) q.push(f->right);
}
x ++;
}
}
int main() {
return 0;
}
层序遍历求树的深度
最新推荐文章于 2022-08-07 19:55:22 发布