Telemetry Price Tracker

An orbital ground station receives price beacons from a telemetry feed. Each beacon carries a timestamp and a price value. Beacons may arrive out of order, and a later beacon can correct an earlier timestamp by overwriting its price. You must maintain the feed so that the following queries are always correct.

Design a class TelemetryTracker that supports:

  • TelemetryTracker() initializes the tracker with no beacons.
  • record(timestamp, price) stores the price at the given timestamp. If the timestamp was already recorded, the old price is replaced.
  • latest() returns the price associated with the largest timestamp among all recorded beacons.
  • peak() returns the maximum price among all recorded beacons.
  • trough() returns the minimum price among all recorded beacons.

All timestamps are positive integers and strictly identify a beacon slot. Prices are positive integers. Every call to latest, peak, and trough is made after at least one beacon has been recorded.

The challenge is to keep latest tied to timestamp order while peak and trough reflect the global price distribution after overwrites.

Examples
Input: [["TelemetryTracker","record","record","latest","peak","trough"],[[],[1,10],[2,5],[],[],[]]]
Output: [null,null,null,5,10,5]
Hints

Telemetry Price Tracker

An orbital ground station receives price beacons from a telemetry feed. Each beacon carries a timestamp and a price value. Beacons may arrive out of order, and a later beacon can correct an earlier timestamp by overwriting its price. You must maintain the feed so that the following queries are always correct.