#199 Binary Tree Right Side View || Leet Code || C++ || Medium || Code + Explanation

preview_player
Показать описание
Given 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.

Example:

Input: [1,2,3,null,5,null,4]
Output: [1, 3, 4]
Explanation:

1 YOU SEE (1)
/ \
2 3 YOU SEE (3)
\ \
5 4 YOU SEE (4)

or

Рекомендации по теме
Комментарии
Автор

no need helper vector !!
Just the final front thoroght iteratin is the right side elm >

zeyadalbadawy
Автор

you dont need helper vector...u can do this : if(i==n-1) output.push_back(node->val)

bharathkumar
join shbcf.ru