FastPrepStationary City Population Shares
Problems/Stationary City Population Shares

Stationary City Population Shares

IMC Trading logoIMC Trading● MediumFULLTIMENEW GRADPHONE SCREEN

Updated Oct 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The stationary population objective matches the reported city-movement question at about 90%. The complete older family reports three cities and separately supplies transitions for its arrival-time follow-up. Reusing that table as a stationary example, general city count, positive row weights, bounds and output tolerance are disclosed practice assumptions.

A population moves among n cities once per day. A person in city i chooses the next city according to the probabilities represented by transitionWeights[i].

Return the stationary population share for each city: the unique nonnegative vector pi with total one and pi[j]=sum(i,pi[i]*P[i][j]). For this exercise, assume positive off-diagonal weights make the chain irreducible. These are the shares that stay the same after a daily transition. Return them even if another starting population would keep cycling between different shares.

For this exercise, assume a general city count and integer row weights are supplied as inputs. Complete stationaryCityShares(transitionWeights). Answers within 1e-9 absolute error per entry are accepted.

Function

stationaryCityShares(transitionWeights: int[][]) → double[]

Examples

Example 1

transitionWeights = [[2,1,1],[1,0,1],[1,1,2]]return = [0.4,0.2,0.4]

In NYC, Nashville, SF order, equilibrium is [0.4,0.2,0.4]. The report supplies this transition table for the separate arrival-time follow-up; reusing it here is an authored stationary example.

Example 2

transitionWeights = [[1]]return = [1.0]

All population stays in the only city.

Example 3

transitionWeights = [[0,1],[1,0]]return = [0.5,0.5]

The population changes city daily. This periodic chain still has stationary shares [0.5,0.5].

Example 4

transitionWeights = [[0,3],[1,2]]return = [0.25,0.75]

City zero always moves to city one; city one returns with probability one third. Balance pi[0]=pi[1]/3 gives [0.25,0.75].

Constraints

  • For this exercise, assume a square matrix of 1 <= n <= 10 cities, with integer weights from 0 through 100.
  • For n>1, every off-diagonal weight is at least one; diagonal weights may be zero. For one city, its sole weight is positive.
  • Each row is normalized independently: P[i][j]=transitionWeights[i][j]/sum(transitionWeights[i]).
  • For this exercise, assume outputs follow input city order and inputs are not modified.

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
  • Valid Range of a Three-Outcome Probability ParameterPHONE 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
  • 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

  • Sliding Window Attention over a KV CacheNVIDIA · PHONE SCREENNVIDIA interview questions
  • Integers With Multiple Sum of Two CubesCharta Health · PHONE SCREEN · ONSITE INTERVIEWCharta Health interview questions
  • Dice-Walk Winning ProbabilityGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
  • Logistic Regression with Gradient DescentYahoo · PHONE SCREENYahoo interview questions
  • Evaluate an Arithmetic Expression Written in WordsBrex · PHONE SCREEN
  • Constant-Time Weighted Pick with an Alias TableEtched · PHONE SCREEN
  • Integer to English Words in USD and INR StylesVeeam · PHONE SCREEN
  • Adaptive Calibration ErrorOpenAI · PHONE SCREENOpenAI interview questions
  • Sum of Smallest Non-DivisorsThe D.E. Shaw Group · PHONE SCREENThe D.E. Shaw Group interview questions
  • Square Root FunctionCitadel · PHONE SCREENCitadel interview questions
All IMC Trading interview questionsSee IMC Trading hiring insights
Saved
class Solution {
    public double[] stationaryCityShares(int[][] transitionWeights) {
        // Write your solution here.
    }
}
Checking account…