You are given an array of positive integers representing the heights of a row of buildings. You are observing these buildings from the far right side (i.e., from a position at infinity on the positive x-axis).
A building is considered to have a "sunset view" if no building to its right is taller than or equal to it.
Your task is to find and return a list of the heights of all buildings that have a sunset view, in the order they appear from left to right in the original array.
Input Format:
The first line of input contains an integer 'N', the number of buildings.
The second line contains 'N' space-separated integers, representing the heights of the buildings.
Output Format:
Print a single line containing the space-separated heights of the buildings with a sunset view, in their original order.
Note:
The rightmost building in the array always has a sunset view.
The most efficient way to solve this is to iterate through the array from right to left, keeping track of the maximum height seen so far.