FastPrepEqual-Weight Portfolio Variance
Problems/Equal-Weight Portfolio Variance

Equal-Weight Portfolio Variance

The D.E. Shaw Group logoThe D.E. Shaw Group● EasyFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a D.E. Shaw phone screen. The report asks for the variance of an equal-weight portfolio where each asset has variance 1, followed by the case where every pair has the same positive correlation. We chose independence for the first version and the numeric limits. Our version is about 95% the same as the reported question.

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) → double

Examples

Example 1

n = 4rho = 0.0return = 0.25

Four independent unit-variance assets with equal weights have variance 4 * (1/4)^2 = 1/4.

Example 2

n = 4rho = 0.2return = 0.4

The four diagonal covariance terms and twelve ordered off-diagonal terms give (4 + 12 * 0.2) / 16 = 0.4.

Constraints

  • 1 <= n <= 10^6.
  • rho is finite and 0 <= rho <= 1.
  • All asset variances are 1, and all weights are exactly 1/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
All The D.E. Shaw Group interview questionsSee The D.E. Shaw Group hiring insights
Saved
class Solution {
    public double portfolioVariance(int n, double rho) {
        // Write your code here.
    }
}
Checking account…