Selecting Stocks
An investor has saved some money and wants to invest in the stock market. There are a number of stocks to choose from, and they want to buy at most 1 share in any company. The total invested cannot exceed the funds available. A friend who is a stock market expert has predicted the values of each stock after 1 year. Determine the maximum profit that can be earned at the end of the year assuming the predictions come true.
Complete the function selectStock in the editor below. The function should return an integer that denotes the maximum profit after one year.
selectStock has the following parameter(s):
- 1.
saving: amount available for investment - 2.
int currentValue[n]: the current stock values - 3.
int futureValue[n]: the values of the stocks after one year
1Example 1
Constraints
Limits and guarantees your solution can rely on.
๐๐