PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/Two Sigma

Match readings with latest same-city humidity

Last updated: Mar 29, 2026

Quick Overview

This question evaluates the ability to align and join time-ordered sensor data by key, testing skills in time-series merging, per-key state management, and handling absent matches.

  • easy
  • Two Sigma
  • Coding & Algorithms
  • Data Scientist

Match readings with latest same-city humidity

Company: Two Sigma

Role: Data Scientist

Category: Coding & Algorithms

Difficulty: easy

Interview Round: Technical Screen

## Problem You are given two time-sorted lists of sensor readings: - **Temperature** records: `(time, city, reading)` - **Humidity** records: `(time, city, reading)` Example: **Temperature** ```text [(1, 'NYC', 12), (5, 'SFO', 20), (7, 'NYC', 23), (16, 'SFO', 10)] ``` **Humidity** ```text [(0, 'SFO', 12), (3, 'SFO', 2), (6, 'NYC', 2), (19, 'SFO', 9)] ``` ### Task For each temperature record, match it with the **most recent humidity record from the same city** whose `time <= temperature_time`. - If there is no earlier humidity record for that city, return `null` (or `None`) for the humidity reading. ### Output Return a list aligned to the temperature records, where each element includes the temperature record and the matched humidity reading (or `null`). ### Constraints - Both input lists are individually sorted by time ascending. - Cities may appear in any order within the global time ordering.

Quick Answer: This question evaluates the ability to align and join time-ordered sensor data by key, testing skills in time-series merging, per-key state management, and handling absent matches.

Related Interview Questions

  • Implement Price-Time Order Matching - Two Sigma (medium)
  • Compute Piecewise Linear Interpolation - Two Sigma (medium)
  • Implement an In-Memory Database - Two Sigma (hard)
  • Merge two sorted linked lists - Two Sigma (hard)
  • Merge Two Sorted Lists - Two Sigma (hard)
Two Sigma logo
Two Sigma
Dec 15, 2025, 12:00 AM
Data Scientist
Technical Screen
Coding & Algorithms
6
0

Problem

You are given two time-sorted lists of sensor readings:

  • Temperature records: (time, city, reading)
  • Humidity records: (time, city, reading)

Example:

Temperature

[(1,  'NYC', 12),
 (5,  'SFO', 20),
 (7,  'NYC', 23),
 (16, 'SFO', 10)]

Humidity

[(0,  'SFO', 12),
 (3,  'SFO', 2),
 (6,  'NYC', 2),
 (19, 'SFO', 9)]

Task

For each temperature record, match it with the most recent humidity record from the same city whose time <= temperature_time.

  • If there is no earlier humidity record for that city, return null (or None ) for the humidity reading.

Output

Return a list aligned to the temperature records, where each element includes the temperature record and the matched humidity reading (or null).

Constraints

  • Both input lists are individually sorted by time ascending.
  • Cities may appear in any order within the global time ordering.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Two Sigma•More Data Scientist•Two Sigma Data Scientist•Two Sigma Coding & Algorithms•Data Scientist Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.