Anti-entropy convergence rounds

Write codeMedium30 minAmazon style

Your task

A set of replicas runs pairwise anti-entropy to converge on the freshest version of a single key. Each replica i starts with an integer version versions[i] (higher is fresher). A schedule lists pairwise sync rounds in order; each round is [i, j] meaning replicas i and j exchange and both adopt max(version_i, version_j). After running every scheduled round in order, return the number of replicas that hold the globally maximum version. This models how many replicas have converged to the latest write after a given anti-entropy schedule.

Examples

converged_count(versions: list[int], schedule: list[list]) -> int
Example 1
Inputconverged_count([5, 1, 1], [[0, 1], [1, 2]])
Output3