Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You have gone fishing in the river. The river is located to the right of the buildings. There are n buildings in a line. You

You have gone fishing in the river. The river is located to the right of the buildings. There are
n buildings in a line.
You are given an integer array of heights of size n that represents the heights of the buildings
in the line.
A building has a river view if the building can see the river without obstructions. Formally, a
building has a river view if all the buildings to its right have a smaller height.
Return a list of indices (0-indexed) of buildings that have a river view, sorted in increasing
order.
Requirements
1. Implement the above problem statement using Stacks.
2. Analyze the time complexity of your algorithm.
3. Implement the above problem statement using Python 3.7.
4. Make sure proper exception handling is written for the code.
Sample Input
Input should be taken in through a file called inputPS01.txt which has the fixed format
as below:

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions