![](https://img-blog.csdnimg.cn/direct/50625020b1f14631a6c6fee4c60a6dd3.png)
class Solution {
public:
int calculateDepth(TreeNode* root) {
int i = 0;
if(!root) return i;
queue<TreeNode*> q;
q.push(root);
while(!q.empty())
{
for(int j = q.size();j>0;j--)
{
TreeNode* tmp = q.front();
q.pop();
if(tmp->left) q.push(tmp->left);
if(tmp->right) q.push(tmp->right);
}
i++;
}
return i;
}
};
![](https://img-blog.csdnimg.cn/direct/f6aeea3379874739858043aeb3c20c00.png)
class Solution {
public:
bool isPerfectSquare(int num) {
if(num < 0) return false;
if(num == 0 || num == 1) return true;
int j = 1;
while(num>0)
{
num -= j;
j += 2;
}
if(num < 0) return false;
return true;
}
};