Company: IBM sde
Difficulty: medium
A distributed system generates event logs. Due to a network issue, logs arrived out of order and some were duplicated. Each log entry has the format T<timestamp>:<event_id> where timestamp is a non-negative integer. Given N such log strings (with duplicates possible), you must: Deduplicate – same timestamp + same event_id = duplicate, keep only one. Sort by timestamp ascending. Break ties by event_id lexicographically. Output only the event_ids , one per line, in final order. Input Format: Line 1: Integer N (1 ≤ N ≤ 10 5 ) Lines 2..N+1: Log strings of the form T<ts>:<event_id> where 0 ≤ ts ≤ 10 9 , event_id is alphanumeric with underscores Output Format: Event IDs in sorted order, one per line Example: Input: 7 T10:db_write T5:auth_check T10:db_read T5:auth_check T3:boot T10:db_write T7:cache_miss Output: boot auth_check cache_miss db_read db_write T5:auth_check appeared twice → deduped to one. Sorted: T3 → T5 → T7 → T10(db_read before db_write lexicographically