Beats 100% Users on Runtime|| DFS(Preorder)|| O(n) Time Complexity || O(h) Space Complexity||
Intuition\nWe just traverse and keep track of the nodes cuurmaxlevel and its curr level,For every first instance where level >currmaxlevel, we update the answer
# Intuition\nWe just traverse and keep track of the nodes cuurmaxlevel and its curr level,For every first instance where level >currmaxlevel, we update the answer with the roots value and thus get the final desired output.\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:o(Number of Nodes)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:o(Height of Tree)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\n/**\n * Definition for a binary tree node.\n * struct TreeNode {\n *     int val;\n *     TreeNode *left;\n *     TreeNode *right;\n *     TreeNode() : val(0), left(nullptr), right(nullptr) {}\n *     TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n *     TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}\n * };\n */\nclass Solution {\npublic:\n    void  function(TreeNode* root,int level,int &currlevel,int &ans){\n        if(root==NULL){return ;}\n        if((root->left==NULL && root->right==NULL)){\n            if( (currlevel<level)){\n            currlevel=level;ans=root->val;return ;}\n            else{return ;}\n            }\n        \n        \n        function(root->left,level+1,currlevel,ans);\n        function(root->right,level+1,currlevel,ans);\n    }\n    int findBottomLeftValue(TreeNode* root) {\n        int ans=0;\n        int currlevel=0;\n        function(root,1,currlevel,ans);\n        return ans;\n        \n    }\n};\n```
['C++']