Find Bottom Left Tree Value Posted on 2018-11-07 Descriptionhttps://leetcode.com/problems/find-bottom-left-tree-value/description/ Solution123456789101112131415161718192021222324252627/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */class Solution {public: int findBottomLeftValue(TreeNode* root) { map<int, int> depthMapping; int depth = 0; helper(root, depthMapping, depth); return depthMapping.rbegin()->second; } void helper(TreeNode* root, map<int, int>& depthMapping, int depth) { if (root == NULL) return; helper(root->left, depthMapping, depth + 1); auto iter = depthMapping.find(depth); if(iter == depthMapping.end()) depthMapping[depth] = root->val; helper(root->right, depthMapping, depth + 1); return; }};