Question: Given an array A [ 1 . . n ] which represents a daily stock price of a particular stock. You are allowed 4 transactions,

Given an array A[1..n] which represents a daily stock price of a particular stock. You are
allowed 4 transactions, 2 buys and 2 sells. Each transaction can involve exactly one stock.
And only one transaction per day is allowed. Give an algorithm to find what is the maximum
profit one can make. For full credits, your algorithm must run in O(n)(Note: Goldman Sachs
interview question)
Given an array A [ 1 . . n ] which represents a

Step by Step Solution

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 Programming Questions!