BackmediumStrings strings medium

Earliest Messages By Timestamp Solution

Problem Statement

Given a list of message pairs, where each pair contains a unique message identifier and a timestamp, determine the earliest message received from each unique timestamp.

Example 1
Input
[[1, 10], [2, 5], [3, 10], [4, 15]]
Output
[(2, 5), (1, 10), (4, 15)]

Explanation: The earliest message at timestamp 5 is (2, 5), at timestamp 10 is (1, 10), and at timestamp 15 is (4, 15).

Constraints

  • 1 <= number of messages <= 10^5
  • 1 <= message identifier <= 10^9
  • 1 <= timestamp <= 10^9
  • All message identifiers are unique
  • All timestamps are non-negative integers
Live Compiler
Loading...
Test Cases & Output
🔒 Sign up to run your code

🚀 Practice this problem

Run code, get AI hints & track streak

Sign Up Free