Given a series of positive integers representing the prices of a single stock on various days (in the array each index represents a different day). Also, there is a list that represents the number of actions you are allowed to take. integer is given. A transaction is the purchase of a stock on a particular day and another day the next. is sold on the date. Returns the maximum profit you can make by buying and selling stocks, given X trades. will be written in c# code write a function. Note that you can only own one share of the stock at a time; in other words, You cannot buy more than one share of the stock on any given day and still have another share. You cannot buy a share of the stock if you own it. Also, all allowed x operations You don't need to use it. will be written in c# code sample entry: prices = [5, 11, 3, 50, 60, 90] x = 2 sample output: 93 // Buy: 5, Sell: 11; Buy: 3, Sat: 90 This is how the code will be written: public static int Max Profit in Trading(int[] prices, int Number of Transactions, out int[] Trades) { // code return -1; } write a function. Note that you can only own one share of the stock at a time; in other words, You cannot buy more than one share of the stock on any given day and still have another share. You cannot buy a share of the stock if you own it. Also, all allowed x operations You don't need to use it.
Given a series of positive integers representing the prices of a single stock on various days (in the array
each index represents a different day). Also, there is a list that represents the number of actions you are allowed to take.
integer is given. A transaction is the purchase of a stock on a particular day and another day the next.
is sold on the date.
Returns the maximum profit you can make by buying and selling stocks, given X trades.
will be written in c# code
write a function.
Note that you can only own one share of the stock at a time; in other words,
You cannot buy more than one share of the stock on any given day and still have another share.
You cannot buy a share of the stock if you own it. Also, all allowed x operations
You don't need to use it.
will be written in c# code
sample entry:
prices = [5, 11, 3, 50, 60, 90]
x = 2
sample output:
93 // Buy: 5, Sell: 11; Buy: 3, Sat: 90
This is how the code will be written:
public static int Max Profit in Trading(int[] prices, int Number of Transactions, out int[] Trades) {
// code
return -1;
}
write a function.
Note that you can only own one share of the stock at a time; in other words,
You cannot buy more than one share of the stock on any given day and still have another share.
You cannot buy a share of the stock if you own it. Also, all allowed x operations
You don't need to use it.
Step by step
Solved in 2 steps with 1 images