Question: Coding language required: C You are given a sequence of stock prices over n days. For each stock price, print the span of the stock

Coding language required: C

You are given a sequence of stock prices over n days. For

You are given a sequence of stock prices over n days. For each stock price, print the span of the stock on that day, which is the maximum number of consecutive days for which the stock price was less than or equal to the price on the present day. The calculation of span includes the current day. The first line of input is n, the number of stock prices, while the second line is a space-separated list of stock prices. You are expected to output a space-separated list of n integers where the ith integer is the span of the stock price on the ith day.

Step by Step Solution

3.47 Rating (154 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Algorithms Questions!