Breadth-First Search pattern
Rightmost Node
Given the root of a binary tree, imagine standing on its right side and return the values of the nodes visible from top to bottom, that is the rightmost node of each level. Watch it run step by step, then write your own pseudocode and get it checked by AI.
- LeetCode 199
- Medium
- 1 approach
Sign in with Google or GitHub and you land straight on this page. DSA comes with the all labs plan and every ChaiCode batch.
Breadth-First SearchLeetCode 199
Medium
The approach
- 01 BFS, take last of level O(n)O(width) space
What you will learn
- How to read Rightmost Node and spot the breadth-first search pattern in it
- BFS, take last of level: O(n) time, O(width) space
- The pseudocode for each approach, its line lit as the animation runs
- Practice: write your own pseudocode and get it checked
More Breadth-First Search
See Rightmost Node run, step by step
Sign in and this page opens on the animation, with all 8 Breadth-First Search problems beside it.
DSA comes with the all labs plan and every ChaiCode batch.