Coding Challenge: Binary Tree View from the Right Side

The Problem:

Given the root of a binary tree, return the view from the right-hand side of the tree. See the example image below:

  • Determine all the values on that level
  • Take the last value on that level and add it to our results list.
  • Once we reach a level that has no values we can assume we have traversed the entire tree as there are no more nodes.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store