InterviewDB
Question
Portfolio Value Optimization: Allocate Budget Across Assets with Risk Constraints
phone
Question Details
Problem
You have a budget B (integer units) to allocate across n assets. Asset i has a function value[i][k] representing the value gained by investing k units in it (non-decreasing, not necessarily linear). You also have a risk score risk[i][k] for each investment level, and a total risk cap R. Maximize total portfolio value without exceeding B or R.
python
def max_portfolio_value(
value: list[list[int]], # value[i][k]: value of investing k units in asset i
risk: list[list[int]], # risk[i][k]: risk of investing k units in asset i
B: int,
R: int
) -> int:
pass
Example
**Input**:
value = [[0,3,5,6], [0,4,6,7], [0,2,4,8]]
risk = [[0,1,2,4], [0,2,3,5], [0,1,3,6]]
B = 4, R = 6
**Output**: 11
# Allocate 1 to asset 0 (v=3,r=1), 1 to asset 1 (v=4,r=2), 2 to asset 2 (v=4,r=3)
# total value=11, total risk=6, total budget=4
Follow-ups
- What is the time complexity of your DP solution? Can you improve space usage?
- How would you handle fractional allocations (continuous version)?
- What changes if risk is a covariance matrix rather than per-asset scalars?
Full Details
Problem
You have a budget B (integer units) to allocate across n assets. Asset i has a function value[i][k] representing the value gained by investing k units in it (non-decreasing, not necessarily linear). You also have a risk score risk[i][k] for each investment level, and a total risk cap R. Maximize total portfolio value without exceeding B or R.
python
def max_portfolio_value(
value: list[list[int]], # value[i][k]: value of investing k units in asset i
risk: list[list[int]], # risk[i][k]: risk of investing k units in asset i
B: int,
R: int
) -> int:
pass
Example
**Input**:
value = [[0,3,5,6], [0,4,6,7], [0,2,4,8]]
risk = [[0,1,2,4], [0,2,3,5], [0,1,3,6]]
B = 4, R = 6
**Output**: 11
# Allocate 1 to asset 0 (v=3,r=1), 1 to asset 1 (v=4,r=2), 2 to asset 2 (v=4,r=3)
# total value=11, total risk=6, total budget=4
Follow-ups
- What is the time complexity of your DP solution? Can you improve space usage?
- How would you handle fractional allocations (continuous version)?
- What changes if risk is a covariance matrix rather than per-asset scalars?
Free preview. Unlock all questions →
Topics
Coding
Onsite
Phone
More from Robinhood
Reddit
Robinhood SWE Interview
Reddit
Robinhood mobile SWE interview experience
1p3a
Robinhood Frontend Engineering Onsite Interview Experience and Challenges
1p3a
Robinhood Fulltime SDE Technical Phone Screen Interview Experience
1p3a
Robinhood software engineer coding interview on fractional shares inventory