The interview problem

Practice prompt

Design a nightly forecasting system for 500,000 spare-part/location pairs. Many have fewer than five demand days per year. Produce a distribution of total demand over a 14-day protection period and explain how it supports replenishment decisions. Address long runs of zeros, new parts, retirement, uncertain lead times and evaluation when shortages are rare but costly.

Original ML-design practice, not a reported company interview. Workloads, costs and worked examples are illustrative. Sources retrieved September 27, 2026; source dates are recorded below; interview date not applicable.

1. Define demand and the decision horizon

Predict requested units, not merely shipped units. A zero can mean no demand, no active equipment requiring the part, missing telemetry or no stock available to sell. Those states require different treatment. Preserve genuine observed zeros and mark missing or censored observations explicitly. Returns belong in a separate process rather than becoming negative demand in a positive-count model.

The protection period is the interval that available stock must cover before a replenishment opportunity can serve demand. Start with a fixed 14-day horizon. Under periodic review it may include both review delay and supplier lead time; the business must specify that timing. Return the horizon, forecast origin, model/data versions, mean, selected quantiles and a reproducible distribution representation.

The forecasting service estimates uncertainty. A separate policy applies current inventory position, pack sizes, minimum orders, budgets and criticality rules. The forecast mean is not automatically an order quantity. Inventory position can include on-hand stock, outstanding orders and backorders, but an order arriving after the protection period cannot be treated as stock available today.

2. Build an exposure-aware forecasting pipeline

demand requests + stock availability + asset registry
                         ↓
           daily panel with explicit observation status
                         ↓
         features available at each forecast origin
                         ↓
           occurrence model + positive-size model
                         ↓
      joint demand paths → protection-period totals
                         ↓
      inventory policy and operational constraints
                         ↓
      versioned recommendation → outcome monitoring

Maintain stable part identifiers, supersession mappings, location history, installed equipment counts, age, maintenance schedules and supplier lead-time records. Keep the feature values that were actually known at each historical origin. A maintenance plan revised after a failure must not appear as a predictive feature before that failure.

Pool information across similar parts and locations rather than fitting a complex independent model to each two-event history. Evaluate that pooling: an expensive safety-critical component should not inherit a generic consumption rate from a superficially similar consumable. Use lifecycle and exposure features, with uncertainty that reflects limited observations.

Key each output by part/location, forecast origin, model version and input-data revision. Retrying the same version must not duplicate recommendations; a corrected input revision must explicitly supersede the previous output. Publish only after validating coverage, distributions and input freshness. A failed refresh should expose the last forecast's age and route critical decisions for review; silently replacing every missing forecast with zero is an inventory policy change.

3. Establish baselines and explain their limits

Compare a zero point forecast, a pooled mean-rate forecast and a Croston-style baseline before adding a larger model. Croston's method smooths positive demand quantities and the intervals between them, then divides the smoothed quantity by the smoothed interval. Classical Croston is a point forecasting method with known bias; it does not supply a predictive distribution on its own. The textbook reference explains these limitations.

For an original update example, suppose the previous smoothed size is 4 units, interval is 10 days and both smoothing parameters are 0.2. A new demand of 6 units arrives after 20 days:

new size     = 0.8 × 4  + 0.2 × 6  = 4.4 units
new interval = 0.8 × 10 + 0.2 × 20 = 12 days
new rate     = 4.4 / 12 ≈ 0.3667 units/day

The previous rate was 0.4 units/day. Between positive arrivals, the classic point estimate remains unchanged; the elapsed gap affects the next interval update. Specify initialization and distinguish a completed interval from an ongoing, right-censored gap. The ratio is neither the probability of demand tomorrow nor a forecast of inventory needed at a service target.

A long zero run may reflect retirement, but it can also be normal for a rare part. Combine asset retirement records and lifecycle evidence with demand history. Do not remove coverage for a critical part solely because its recent history contains zeros.

4. Model occurrence, size and dependence

A hurdle model separates whether demand occurs from its positive quantity. For context x, let p(x) be the probability of a positive-demand day and let g(y|x) be a distribution supported on positive integers:

P(Y = 0 | x) = 1 − p(x)
P(Y = y | x) = p(x) g(y | x), for y > 0
E[Y | x]     = p(x) E[Y | Y > 0, x]

Fit occurrence on all eligible observed days and positive size on positive-demand days. A positive-size component must be normalized over positive values; an ordinary count distribution that also assigns mass to zero cannot be inserted unchanged. Calibrate both components and examine results by history length, part family and exposure.

Independent daily arrivals are a useful baseline. Scheduled maintenance can generate clusters, while elapsed time since the previous event can affect arrival probability. Renewal-process models offer a framework for duration-dependent arrivals; the cited research supports that modeling direction, not a claim that it wins on this workload. During simulation, advance elapsed time on zero-demand days and reset it when an event occurs; update other state along each sampled path.

Sum demand along coherent future paths to obtain protection-period totals. Adding daily marginal quantiles is generally invalid. If disruptions simultaneously lengthen supplier lead times and increase demand, independent sampling of those quantities can understate the tail. Start with measured dependencies and compare simpler models; a more complicated simulator does not create evidence that the tail is correct.

5. Work through forecast loss versus inventory cost

For a hand-computable example, daily demand is 4 units with probability 0.05 and zero otherwise, independently across 14 days. This is more frequent than demand for the sparsest parts in the prompt. The daily mean is 0.2 units.

Daily point forecastExpected absolute errorExpected squared error
00.05 × 4 = 0.200.05 × 16 = 0.80
0.20.95 × 0.2 + 0.05 × 3.8 = 0.380.95 × 0.04 + 0.05 × 14.44 = 0.76

Absolute error favors the zero median; squared error favors the mean. Neither point forecast specifies the inventory decision. Over 14 days, N is binomial with parameters 14 and 0.05, total demand D = 4N, and E[D] = 2.8 units.

Assume initial stock S is available at the start, no replenishment occurs during the period, a multi-unit request can be partially fulfilled, and there are no substitutions or returns. Charge 1 cost unit per leftover unit and 9 per unserved unit. These are illustrative single-period decision costs, not purchase prices or a dynamic replenishment model.

C(S) = E[max(S − D, 0) + 9 max(D − S, 0)]
C(S + 1) − C(S) = 10 P(D ≤ S) − 9

For nonnegative integer stock, a cost-minimizing choice is the smallest S whose demand CDF reaches 0.9. Here that is 8 units, rather than rounding the mean 2.8 to 3. Exact enumeration gives:

Initial stockExpected costProbability of no shortageUnit fill fraction
025.200048.77%0%
312.830248.77%54.89%
48.707084.70%73.19%
86.587696.99%95.04%
129.385499.58%99.34%

The unit fill fraction here is 1 − E[max(D − S, 0)] / E[D]. It differs from the probability of no shortage and from averaging a fill ratio across individual periods. The latter is undefined on a zero-demand period unless a convention is supplied. Stock 3 serves some units but cannot fully cover even one four-unit arrival.

Discrete demand makes the achieved no-shortage probability jump above the 90% cost threshold. A 95% cycle-service constraint also selects stock 8 in this particular example, but that coincidence does not make cost minimization equivalent to a universal 95% target. Repeated ordering, backorder timing and shared capacity require a policy simulation with their own assumptions.

6. Budget state and simulation work

A dense panel of 500,000 pairs over 730 days has 365 million rows. At an illustrative 32 bytes of logical payload per row, that is 11.68 GB before additional features, indexes, replicas and storage overhead. Sparse storage can help, but it must retain enough calendar and exposure information to distinguish zero from absent data.

Sampling 1,000 paths of 14 days for every pair requires seven billion simulated day steps each night. Batch the work, use exact distributions where practical, and allocate extra samples to decisions whose tail uncertainty changes the order quantity. Repeated simulation can reduce Monte Carlo noise; it does not reduce uncertainty caused by having observed only one failure in production.

Store seeds or reproducible distribution parameters, model version and policy inputs with each recommendation. Use checks for valid probability mass, nonnegative demand and monotonic quantiles. Track missing forecasts and runtime by cohort so the rarest items are not silently skipped when a batch exceeds its deadline.

7. Evaluate sparse forecasts without hiding failures

Use rolling forecast origins with features available at the time and fully observed future protection periods. Preserve long zero histories. Testing only days with positive demand measures a different problem and cannot evaluate occurrence probability. Conversely, an all-zero test period says little about shortage behavior.

Report occurrence calibration, positive-size fit, protection-period quantile coverage and cost/service under a specified policy. Break results down by criticality, age, history density and lifecycle state. Avoid percentage errors that divide by zero; aggregate metrics can also conceal the small set of expensive critical parts. Compare inventory policies on the same demand paths and assumptions.

Overlapping 14-day evaluation windows are correlated. Use uncertainty procedures that respect time and part dependence, such as an appropriate block design, rather than treating each origin as an independent experiment. Include intervals for rare-event metrics and report how many positive events support the assessment.

Audit future maintenance revisions, retroactively corrected retirement status and eventual supplier arrival times for leakage. A final lead time can be a historical outcome; it cannot be a feature that was already known when the order was placed. Shadow the policy before changing orders, then monitor realized service, inventory and overrides together.

8. Failure cases and trade-offs

  • Unavailable stock looks like no demand: use requested demand and availability records where possible; otherwise identify the censoring assumption and route to the separate stockout-modeling problem.
  • Part supersession: reconcile identifiers and compatibility before borrowing history. A replacement may serve a different installed base.
  • Maintenance bursts: independent days miss common-cause demand. Model known schedules and evaluate clustered scenarios without claiming every burst is predictable.
  • Obsolescence: keeping a stale positive rate forever wastes inventory, while aggressively decaying a critical rare part to zero risks service. Use lifecycle evidence and explicit policy review.
  • One-event certainty: pooling reduces variance but can hide uncertainty and cohort mismatch. Retain conservative operational constraints where evidence is thin.
  • Wrong objective: a model selected solely by absolute error can predict zero almost everywhere. Select distributions and policies against the actual cost and service contract.

9. Interview follow-ups

  • What changes with uncertain lead time? Forecast demand over the sampled arrival horizon and preserve relevant demand/lead-time dependence.
  • What if positive sizes are also highly variable? Model the positive-size tail and its relationship with maintenance type rather than fixing every arrival at the mean.
  • How do you launch a new part? Use compatible cohort and exposure information, disclose uncertainty and update as outcomes arrive.
  • What if stock is shared across locations? Add transfer delays, allocation and shared budget constraints; independent per-location quantiles do not solve the network policy.

Self-review rubric

A strong answer distinguishes zero, missing and censored observations; separates occurrence from positive size; produces cumulative uncertainty; and explains why mean, median and inventory target differ. It calculates the example correctly, distinguishes cycle service from unit fill, and states the limits of the single-period cost model. An excellent answer handles lifecycle changes, dependent arrivals, feature availability and sparse-tail validation without pretending simulation replaces data.

Sources and attribution

Both sources retrieved September 27, 2026. The prompt, architecture, numerical example and operational design are original practice material. These sources validate technical background and are not evidence of a recently asked company interview question.

Continue your preparation

Choose a connected learning path or browse more ML system design questions. Read our editorial method and attribution policy.