Number of Buildings Facing Sun

Given an array representing heights of buildings, the array has buildings from left to right. Count number of buildings facing the sunset. It is assumed that heights of all buildings are distinct.


[2, 3, 4, 5] should return 4 since each one of the buildings can see the sun.

[5, 4, 3] should return 1 since only the first building can see the sun.

Contributed by Berkan Teber