Equal-Weight Portfolio Variance
Updated
Problem statement
A portfolio contains n assets. Each asset’s return has variance 1, and each asset makes up 1/n of the portfolio. The returns of any two different assets have the same correlation rho. Return the variance of the weighted portfolio return.
For this exercise, assume 0 <= rho <= 1. The value rho = 0 is the independent-assets baseline; positive values model the common positive-correlation follow-up. The covariance of distinct unit-variance returns is therefore rho.
Return a floating-point number. Answers are accepted within relative or absolute tolerance 10^-6.
Function
portfolioVariance(n: int, rho: double) → doubleExamples
Example 1
n = 4rho = 0.0return = 0.25Four independent unit-variance assets with equal weights have variance 4 * (1/4)^2 = 1/4.
Example 2
n = 4rho = 0.2return = 0.4The four diagonal covariance terms and twelve ordered off-diagonal terms give (4 + 12 * 0.2) / 16 = 0.4.
Constraints
1 <= n <= 10^6.rhois finite and0 <= rho <= 1.- All asset variances are
1, and all weights are exactly1/n.
More The D.E. Shaw Group interview questions
- IPOPHONE SCREEN · Seen Nov 2026
- Print Numbers in Turn with Three ThreadsPHONE SCREEN · Seen Nov 2026
- Subarray Product Less Than KPHONE SCREEN · Seen Nov 2026
- Koko Eating BananasPHONE SCREEN · Seen Nov 2026
- Sum of Smallest Non-DivisorsPHONE SCREEN · Seen Nov 2026
- Remove the Fewest Magic BeansPHONE SCREEN · Seen Oct 2026
- Count Distinct Rooted-Tree GraftsPHONE SCREEN · Seen Oct 2026
- Decode WaysPHONE SCREEN · Seen Sep 2026
- Maximum L1 Distance Between Equal-Length SubarraysPHONE SCREEN · Seen Jul 2026
- Count Lucky TicketsOA · Seen Nov 2026
Similar questions at other companies
- Parking Fee CalculatorBreeze · PHONE SCREEN
- Merchant Payout Reserve CalculatorStripe · PHONE SCREENStripe interview questions
- Sqrt(x)LinkedIn · PHONE SCREENLinkedIn interview questions
- Automation Pipeline, Part 1: Single WorkerPlaid · PHONE SCREENPlaid interview questions
- Subtract Two Large Number StringsStackAdapt · PHONE SCREENStackAdapt interview questions
- Circular Primes Below a LimitAmazon · PHONE SCREEN
- Palindrome NumberKotak Mahindra Bank · PHONE SCREENKotak Mahindra Bank interview questions
- Streaming AverageXantium · PHONE SCREEN
- Fair Coin from a Biased CoinAnthropic · PHONE SCREENAnthropic interview questions
- Stack Formula InterpreterTypeSafe AI · PHONE SCREEN