#C6803. Sunset View
Sunset View
Sunset View
Given a sequence of building heights, you are required to determine which buildings have a sunset view. A building has a sunset view if it is taller than all the buildings to its right. In mathematical terms, for a building at index ( i ) with height ( h_i ), it has a sunset view if ( h_i > \max{h_{i+1}, h_{i+2}, \dots, h_n} ). The remaining buildings should be output in the same order they appear in the input. If the input is empty, output nothing.
inputFormat
The input is provided as a single line of space-separated integers, where each integer represents the height of a building. The number of buildings can range from 0 to (10^5) and each height is between 1 and (10^9).
outputFormat
Print the heights of the buildings that have a sunset view, separated by spaces.## sample
3 7 8 3 6 1
8 6 1
</p>