Skip to content

Commit

Permalink
add README
Browse files Browse the repository at this point in the history
  • Loading branch information
ductnn committed Dec 25, 2024
1 parent 24a864f commit 6c2a4c2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions leetcode/topic/B-Tree/515/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
## [515. Find Largest Value in Each Tree Row]((https://leetcode.com/problems/find-largest-value-in-each-tree-row/description/))

Given the root of a binary tree, return an array of the largest value in each
row of the tree (0-indexed).

Ex1:
![alt text](image.png)
Input: root = [1,3,2,5,3,null,9]
Output: [1,3,9]

Ex2:
Input: root = [1,2,3]
Output: [1,3]

### Approach

**Breadth-First Search (BFS)**
- We can use BFS to traverse the tree level by level. We will use a queue to store
the nodes at each level.
- For each level, we will find the maximum value and add it to the result array.
- We will repeat this process until we have traversed all levels of the tree.
Binary file added leetcode/topic/B-Tree/515/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6c2a4c2

Please sign in to comment.