← Back to companies
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/$
You are given a fixed cash budget and a list of securities. For each security i you know its current price P[i], its expected future price S[i], and the maximum number of shares you are allowed to buy A[i]. Your goal is to decide how many shares of each security to purchase so that the total amount spent does not exceed the budget and the total future value of the portfolio is maximized. Equivalently, maximize the total profit = Σ shares[i] * (S[i] – P[i]) subject to Σ shares[i] * P[i] ≤ budget and 0 ≤ shares[i] ≤ A[i] for every i. Return the maximum achievable total future value (cash invested + profit).