1、题目描述
2、问题分析
使用层序遍历思想
3、代码
int findBottomLeftValue(TreeNode* root) {
if (root == NULL)
return ;
queue<TreeNode*> q;
q.push(root); int val = ;
while (!q.empty()) {
int size = q.size();
for(int i = ; i < size; i++) {
TreeNode *node = q.front();
if (node->left != NULL)
q.push(node->left);
if (node->right != NULL)
q.push(node->right); if (i == )
val = node->val;
q.pop();
}
}
return val;
}