Question: PROBLEM 2 ( 1 0 Points ) This problem is the same as # 1 , except you may complete as many buy / sell

PROBLEM 2
(10 Points) This problem is the same as #1, except you may complete as many buy/sell orders as you have to in a given time slice AND you must sell one before you can buy another (except for the very first buy order).
Write the following function taking in an integer vector (vector{1,2,4}$1$2$2$4=>$1+$2=$3{4,2,1}=>$0{1}$1
note on output: buy $1, sell $5, buy $2, sell $4=$4+$2=$6 profit
STARTER CODE
 PROBLEM 2 (10 Points) This problem is the same as #1,

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