Code RoomLamport timestamp assignment
MediumPrep Room Coding #262

Lamport timestamp assignment

CodingDistributed systemsMid–Senior~28 min

Assign Lamport logical timestamps to a sequence of events across processes. Each event is [proc, type, arg]. For type 'local', the process increments its clock by 1. For type 'send', the process increments its clock by 1 and the message is tagged with that clock; `arg` is a message id. For type 'recv', the process sets its clock to max(local_clock, received_timestamp) + 1; `arg` is the message id being received (its send must appear earlier in the list). Every process starts at clock 0. Return the list of assigned Lamport timestamps, one per event in input order.

Implement
lamport_timestamps(events: list[list]) → list[int]
Examples
in[[["P1","local",null],["P1","send","m1"],["P2","recv","m1"]]]out[1,2,3]
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 28 min
InputExpectedGot
[[["P1","local",null],["P1","send","m1"],["P2","recv","m1"]]][1,2,3]not run yetsample