FastPrepDaily Temperature By Town
Problems/Daily Temperature By Town

Daily Temperature By Town

Two Sigma logoTwo Sigma● HardFULLTIMENEW GRADINTERNOA

Updated Nov 2026

QuestionConstraints

Problem statement

Source note: The report specifies six temperature and regression analyses. It leaves out the exact table, the tie rules, the rounding, and the output format. Our version is about 90% the same as the reported question.

For this exercise, assume the input contains daily temperatures for NYC and six predictor towns named Town1 through Town6. Produce exactly six analysis rows.

  1. Among NYC and all six towns, find the place with the largest population standard deviation of temperature.
  2. Take the median NYC temperature among rows where Town2 is between 90 and 100, inclusive. Use 0 when there are no such rows, then round to the nearest integer.
  3. For each town independently, fit ordinary least squares with an intercept to predict NYC from that town. Sum the absolute values of the six slope coefficients, excluding intercepts, then round to the nearest integer.
  4. Find the single town whose intercept-based model has the smallest training mean squared error.
  5. Find the pair of towns whose joint intercept-based model has the smallest training mean squared error.
  6. Select five towns by forward greedy selection. Starting with no towns, repeatedly add the unused town that gives the smallest training mean squared error when fit jointly with the already selected towns and an intercept.

For every exact score tie, choose the lexicographically smaller place name or comma-joined town list. Round halfway values away from zero. All supplied predictor matrices have a unique least-squares solution.

Return columns metric, towns, and value in the exact row order above. Use null for towns on the two numeric-only rows and for value on the maximum-standard-deviation row. Pair names are comma-joined in lexicographic order; the five-town list is comma-joined in greedy selection order. The value for the last three selection rows is that model's training mean squared error.

Table schema

Pandas

Use the same input data with any supported language. Open the Schema tab in the editor to see the generated SQL setup or Pandas DataFrames.

temperatures

One row per observed day, with NYC as the regression target and six town predictors.

ColumnTypeNullableDescription
day_idPKIntegerNo—
NYCDecimalNo—
Town1DecimalNo—
Town2DecimalNo—
Town3DecimalNo—
Town4DecimalNo—
Town5DecimalNo—
Town6DecimalNo—

Expected result

Your query or function must return these columns.

ColumnTypeNullableDescription
metricTextNo—
townsTextYes—
valueDecimalYes—

Row order: must match exactly. Numeric tolerance: 0.000001.

Constraints

  • The temperatures table has between 8 and 1000 rows.
  • day_id values are distinct; input row order does not affect the result.
  • Every temperature is a finite decimal with absolute value at most 10^6.
  • NYC and all six town columns contain no missing values.
  • Every tested predictor matrix, including the intercept column, has a unique least-squares solution.
  • Decimal results are compared with absolute tolerance 10^-6.

More Two Sigma Online Assessment questions

  • IPO Share AllocationOA · Seen Sep 2026
  • Sewer Drainage PartitionOA · Seen Sep 2026
  • Linear InterpolatorOA · Seen Sep 2026
  • Online No-Intercept Linear RegressionOA · Seen Sep 2026
  • Balanced Split String with WildcardsOA · Seen Aug 2026
  • Closest ColorOA · Seen Aug 2026
  • Piecewise Linear Interpolation and ExtrapolationOA · Seen May 2026
  • Calculate y/x using PatchOA · Seen Nov 2025
  • Nums That Are Divisible by N 🍋OA · Seen Mar 2024
  • Replacing Val 🍓OA · Seen Mar 2024

Similar questions at other companies

  • Town Temperature Regression AnalysisCitadel · PHONE SCREENCitadel interview questions
  • Best Starting Cell for Restaurant DistanceDoorDash · PHONE SCREENDoorDash interview questions
  • Delete and Freeze GameRubrik · OARubrik interview questions
  • Lexicographically Smallest Grid Path with One Letter ChangeInfosys · OAInfosys interview questions
  • Lock CodeVisa · OAVisa interview questions
  • Balance a Chemical EquationMicrosoft · OAMicrosoft interview questions
  • Binary CircuitAkuna Capital · OAAkuna Capital interview questions
  • Hedge Inventory with Return CovarianceMillennium · OAMillennium interview questions
  • Minimize Expression with ParenthesesPinterest · OAPinterest interview questions
  • Lock CodeGoldman Sachs · OAGoldman Sachs interview questions
All Two Sigma interview questionsSee Two Sigma hiring insights