←ENG-DSA-074Visible Security Cameras (Binary Tree Right Side View)
00:00
🐍 Python Idle
Mode:Web

Visible Security Cameras (Binary Tree Right Side View)

CompaniesVerkada, Google
Est. Time~30 min
LevelMid
TreesBFSDFS
🚨 P0 Incident
VerkadaGoogle

Verkada's physical security planning software renders a 2D side-profile of buildings to show camera placement. Given a binary tree representing a building's network topology, the engine must return a list of nodes that are directly visible when the tree is viewed perfectly from the right side.

πŸ“₯ Assigned to:You β€” Mid Engineer
Your Task

Given the `root` of a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.

⏱ Time: O(N)πŸ’Ύ Space: O(N)
Example 1
Input:Β Β Tree:[1,2,3,null,5,null,4]
Output:Β [1, 3, 4]
Example 2
Input:Β Β Tree: [1,2,3,4]
Output:Β [1, 3, 4] (4 is visible because right has no nodes at depth 2)
πŸ”’ +3 hidden test cases β€” revealed on Submit
Hints
Loading editor…
Test Output
β–Ά Run Code to test against examples Β· Submit to judge all 5 test cases
EngPrep β€” Real Engineering. Real Interviews.