Value of a Contract with One Unknown Price
Updated
Problem statement
A stock's price tomorrow will be prices[i] with probability percents[i] / 100. Exactly one of the prices is unknown and is written as -1. You also know the stock's expected price tomorrow, mean; use it to work out the unknown price. The unknown price can be any number that is at least 0, not always a whole number, and it may be larger than 10^4.
A contract pays max(price - strike, 0) dollars tomorrow: the amount by which the final price is above strike, or nothing if it is not above.
Return the expected payoff of the contract (its fair value, with no discounting).
Your answer is accepted if its absolute error or its relative error is at most 10^-9.
Function
callValue(mean: int, prices: int[], percents: int[], strike: int) → doubleExamples
Example 1
mean = 10prices = [15,-1,5,0]percents = [40,10,20,30]strike = 22return = 0.8This is the interview case. The expected price is 10, so 0.4 × 15 + 0.1 × x + 0.2 × 5 + 0.3 × 0 = 10, which gives 6 + 0.1x + 1 = 10 and x = 30.
With a strike of 22, only the $30 outcome pays: 30 - 22 = 8 with chance 0.1. The value is 0.8.
Example 2
mean = 20prices = [-1,10]percents = [50,50]strike = 15return = 7.5Half the time the price is 10, and the mean is 20, so the unknown price is x = 30. The contract pays 30 - 15 = 15 half the time: 7.5.
Example 3
mean = 10prices = [12,-1,0]percents = [30,30,40]strike = 5return = 7.0The unknown price is (1000 - 30 × 12 - 40 × 0) / 30 = 64/3, about 21.33, not a whole number. With strike 5 the contract pays 12 - 5 = 7 with chance 0.3 and 64/3 - 5 = 49/3 with chance 0.3: 2.1 + 4.9 = 7.
Constraints
0 <= mean, strike <= 10^42 <= prices.length == percents.length <= 10-1 <= prices[i] <= 10^4, and exactly oneprices[i]is-11 <= percents[i] <= 100, and the percents add up to100- The unknown price implied by
meanis at least0.
More Susquehanna International Group (SIG) Phone Screen questions
- Dice Sum That Is a Multiple of mPHONE SCREEN · Seen Nov 2026
- Find Median from Data StreamPHONE SCREEN · Seen Nov 2026
- Painting Arcs to Nearest Neighbors on a CirclePHONE SCREEN · Seen Sep 2026
- Filter Movies by Inclusive Year RangePHONE SCREEN · Seen Jul 2026
- Best Single Reroll for Five DicePHONE SCREEN · Seen Feb 2026
- Catching the Bus to the MoviePHONE SCREEN · Seen Jan 2026
- Two Dice Summing to a TargetPHONE SCREEN · Seen Jan 2026
- Median of Uniform Draws in an IntervalPHONE SCREEN · Seen Oct 2025
- One Number Is the Average of the Other TwoPHONE SCREEN · Seen Jun 2025
- Which Coin Pattern Shows Up FirstPHONE SCREEN · Seen May 2025
Similar questions at other companies
- Automation Pipeline, Part 1: Single WorkerPlaid · PHONE SCREENPlaid interview questions
- Employee Count Median, Mean and ModeClay · PHONE SCREEN
- Length of a Document Reached Through a Random TokenMercor · PHONE SCREENMercor interview questions
- Apply Affine Array TransformationsByteDance · PHONE SCREENByteDance interview questions
- Exponential Backoff DelaysWonderful · PHONE SCREEN
- One-Nearest-Neighbor Classification with Manhattan DistanceOpenAI · PHONE SCREENOpenAI interview questions
- Recover Document Hierarchy from IndentationReducto · PHONE SCREEN
- Average Grades per StudentHartford Financial Services · PHONE SCREENHartford Financial Services interview questions
- Through-Origin Linear RegressionMeta · PHONE SCREENMeta interview questions
- Latency Bucket CounterDatadog · OA · PHONE SCREENDatadog interview questions