FastPrepValid Range of a Three-Outcome Probability Parameter
Problems/Valid Range of a Three-Outcome Probability Parameter

Valid Range of a Three-Outcome Probability Parameter

IMC Trading logoIMC Trading● EasyNEW GRADPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The reported probabilities q, q squared and 1-q-q squared match this range calculation at about 90%. This practice task generalizes the coefficient of q squared and returns the valid interval upper endpoint. The separate portfolio-construction follow-up lacks remembered payoffs and constraints, so those details are not supplied.

Three outcomes cannot happen together. Their probabilities are q, weight*q^2 and 1-q-weight*q^2. Find all real values of q that make these three numbers a valid probability distribution.

weight is a nonnegative integer given as input. The first example uses weight one. The valid set is one closed interval [0, upper]. Return its upper endpoint.

Complete maximumValidQ(weight). Answers within 1e-9 absolute error are accepted.

Function

maximumValidQ(weight: int) → double

Examples

Example 1

weight = 1return = 0.6180339887498949

Nonnegativity requires q >= 0 and q+q^2 <= 1. Thus the valid interval is [0,(sqrt(5)-1)/2].

Example 2

weight = 0return = 1.0

The probabilities are q,0,1-q, so the valid range is [0,1].

Example 3

weight = 2return = 0.5

At q=0.5, the probabilities are 0.5,0.5,0. Larger values make the final probability negative.

Example 4

weight = 6return = 0.3333333333333333

The upper endpoint is 1/3 because 1/3+6*(1/3)^2=1.

Constraints

  • 0 <= weight <= 1000000.
  • Zero probabilities are allowed, so both interval endpoints are included.
  • Return the upper endpoint as a double.

More IMC Trading Phone Screen questions

  • Election District Budget Allocation AnalysisPHONE SCREEN · Seen Aug 2026
  • Uniform Variables: Smaller Below Larger SquaredPHONE SCREEN · Seen Mar 2026
  • Combination Sum with Unlimited ReusePHONE SCREEN · Seen Dec 2025
  • Expected Fishing CatchPHONE SCREEN · Seen Dec 2025
  • Count Routes Through a City GridPHONE SCREEN · Seen Nov 2024
  • Expected City Arrival and Return DaysPHONE SCREEN · Seen Nov 2024
  • Stationary City Population SharesPHONE SCREEN · Seen Nov 2024
  • Maximum Falling Path SumPHONE SCREEN · Seen Nov 2024
  • Trading Profit Percentage ChangePHONE SCREEN · Seen Feb 2024
  • Poker Suit Expected ProfitPHONE SCREEN · Seen Sep 2023

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

IMC Trading interview experiences

  • IMC Trading OA: What It Tests (2026)
  • IMC Trading SWE OA and Video: 18 Experiences (Part 3 of 3)
  • IMC Trading SWE OA Questions: 22 Experiences (Part 2 of 3)
  • IMC SWE New Grad OA and Interviews: 58 Experiences (Part 1 of 3)
All IMC Trading interview questionsSee IMC Trading hiring insights
Saved
class Solution {
    public double maximumValidQ(int weight) {
        // Write your solution here.
    }
}
Checking account…