diff --git a/problems/0513.找树左下角的值.md b/problems/0513.找树左下角的值.md index 19c870c3..538b335f 100644 --- a/problems/0513.找树左下角的值.md +++ b/problems/0513.找树左下角的值.md @@ -217,7 +217,31 @@ public: Java: - +```java +class Solution { + public int findBottomLeftValue(TreeNode root) { + Queue queue = new LinkedList<>(); + queue.offer(root); + int res = 0; + while (!queue.isEmpty()) { + int size = queue.size(); + for (int i = 0; i < size; i++) { + TreeNode poll = queue.poll(); + if (i == 0) { + res = poll.val; + } + if (poll.left != null) { + queue.offer(poll.left); + } + if (poll.right != null) { + queue.offer(poll.right); + } + } + } + return res; + } +} +``` Python: