leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

0513.cpp (390B)


      1 class Solution {
      2   public:
      3     int findBottomLeftValue(TreeNode *root) {
      4         queue<TreeNode *> q({root});
      5 
      6         int res = -1;
      7         while (!q.empty()) {
      8             TreeNode *root = q.front();
      9             q.pop();
     10             res = root->val;
     11             if (root->right) q.push(root->right);
     12             if (root->left) q.push(root->left);
     13         }
     14 
     15         return res;
     16     }
     17 };