Your question is Mobile Chat Event Ordering. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Given a list of chat events for a mobile messaging system, reconstruct the visible conversation state. Each event is one of: send, deliver, read, edit, or delete, and includes a message_id, timestamp, and optional fields such as text or user_id. Events may arrive out of order and may be duplicated. Return the final ordered list of non-deleted messages with their latest text and highest status (sent < delivered < read).
def reconstruct_chat(events):