Consistent hashing ring
Build a consistent-hashing ring used to assign keys to storage nodes. The ring has 2^16 = 65536 slots. Each physical node is placed at `vnodes` virtual positions computed deterministically as h(node_id, i) = (i * 2654435761 + sum(ord(c) for c in node_id) * 40503) % 65536 for i in 0..vnodes-1. A key hashes to position k(key) = (sum(ord(c) for c in key) * 2654435761) % 65536. A key is owned by the first node position at or clockwise after k(key) (wrapping around). Process operations: ["add", node_id], ["remove", node_id], and ["owner", key]. Return the list of owner results (the owning node_id, or empty string "" if the ring has no nodes), in order. If two virtual nodes land on the same slot, the one added earlier wins that slot.
consistent_hash_ring(vnodes: int, ops: list[list]) → list[str][1,[["add","alpha"],["add","beta"],["owner","x"],["owner","y"]]]out["alpha","beta"]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.
[1,[["add","alpha"],["add","beta"],["owner","x"],["owner","y"]]]["alpha","beta"]not run yetsample