Read repair stale replicas

Write codeMedium25 minAmazon style

Your task

During a read, the coordinator gathers each replica's view of a key as [replica_id, version, value], where higher integer version is fresher and ties are broken by the lexicographically larger value (a deterministic last-write-wins conflict resolver). The winning (version, value) is the freshest under this rule. Return a list of replica_ids (sorted ascending as strings) that are STALE, i.e., whose (version, value) is not equal to the winning pair, because the coordinator must send them the repaired value. If all replicas already agree, return an empty list.

Examples

read_repair_targets(replica_views: list[list]) -> list[str]
Example 1
Inputread_repair_targets([["r1", 5, "blue"], ["r2", 5, "blue"], ["r3", 4, "red"]])
Output["r3"]