Question
A PN-counter is a CRDT supporting increments and decrements that converges across replicas without coordination. Each replica keeps two grow-only maps per node: P (total increments per node) and N (total decrements per node). To merge a set of replica states you take, for every node, the maximum P and maximum N seen across all replicas; the counter's value is sum(P) - sum(N). Each replica state is given as [P_dict, N_dict]. Given a list of replica states, return the converged integer value after merging them all.
pn_counter_value(replicas: list[list]) → int[[[{"a":5,"b":2},{"a":1}],[{"a":3,"b":4},{"a":1,"c":2}]]]out6State 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.
Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.