Record Log

Problem Overview

  • Build a log server with recordLog, getLogs, and getLogCount to manage logs in a 1-hour sliding window.
  • Each log has integer logId and timestamp (seconds); IDs may repeat and logs can arrive out of order.
  • getLogs returns up to m latest logs from the last hour as a comma-separated list, sorted by timestamp with arrival-order ties; getLogCount returns the total logs in that window (not capped).
  • Constraints: 1 ≤ m ≤ 1000, 1 ≤ q ≤ 1e6; real-time logging context; asked in Optiver interviews as a coding interview problem/interview question.

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: