For instance, consider an input array of [4, 2, 3, 1]. We begin with the last building. The highest height we've seen so far is 0. The height of the last building is 1, which exceeds 0. Therefore, it can see the sea. The first element in our result array is 1, and the maximum height is now 1. The next building has a height of 3, which can also see the sea since it is greater than the current maximum height of 1. We then add 3 to the result array and update the maximum height to 3. The following building has a height of 2, but it cannot see the sea because it is less than the maximum height of 3. Finally, the first building has a height of 4, which can see the sea as it surpasses the maximum height of 3. Thus, we add 4 to the result array, making the maximum height now 4. Consequently, the final output array is [1, 3, 4].