-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.
The problem can be solved using simple recursive traversal. We can keep track of the level of a node by passing a parameter to all recursive calls. The idea is to keep track of the maximum level also. And traverse the tree in a manner that the right subtree is visited before the left subtree. Whenever we see a node whose level is more than the maximum level so far, we print the node because this is the last node in its level (Note that we traverse the right subtree before the left subtree)
-visual studio code platform is used
[ ] Bug fix (non-breaking change which fixes an issue)
[x] New feature (non-breaking change which adds functionality)
[x] Breaking change (fix or feature that would cause existing functionality to change)
This PR is stale because it has been open 3 days with no activity. Please commit the changes requested or make improvements on the code. Thank you for your contributions!
Related Issue
Proposed Changes
Additional Info
Checklist
-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.
https://github.com/Lakhankumawat/LearnCPP/issues/1524
-visual studio code platform is used
Output Screenshots
|