/*
struct TreeNode {
int val;
struct TreeNode *left;
struct TreeNode *right;
TreeNode(int x) :
val(x), left(NULL), right(NULL) {
}
};*/
class Solution {
public:
int TreeDepth(TreeNode* pRoot) {
int l = 0;
if (!pRoot) return 0;
deque<TreeNode*> q;
q.push_back(pRoot);
while(!q.empty())
{
int size = q.size();
l++;
while(size--)
{
TreeNode* p = q.front();
q.pop_front();
if(p->left) q.push_back(p->left);
if(p->right) q.push_back(p->right);
}
}
return l;
}
};