Java DFS & BFS from right to left. 100%
Associate each node with a distance from the root or we call it depth. The bottom level \nmust have the largest depth, but since we want the left most node we s
Associate each node with a distance from the root or we call it depth. The bottom level \nmust have the largest depth, but since we want the left most node we start right child first. \n\n```\nclass Solution {\n    int res = 0;\n    int maxDepth = 0;\n    public int findBottomLeftValue(TreeNode root) {\n        dfs(root, 0);\n        return res;\n    }\n    \n    public void dfs(TreeNode root, int depth){\n        if(root == null) return;\n        if(maxDepth <= depth){\n            res = root.val;\n            maxDepth = depth;\n        }\n        dfs(root.right, depth + 1);\n        dfs(root.left, depth + 1);\n    }\n}\n```\n\nWe can also do this with BFS using a Queue\n```\n//BFS solution: always update root pointer until it points to the last one\n    Queue<TreeNode> queue = new LinkedList<>();\n    queue.add(root);\n    while (!queue.isEmpty()) {\n         root = queue.poll(); // no level size is retrieved because we dont care\n         if (root.right != null)\n             queue.add(root.right);\n         if (root.left != null)\n             queue.add(root.left);\n     }\n     return root.val; // eventually the root pointer will be the bottom left \n```\n
[]