AntInLoop

Counting Sort Game — Cumulative Prefix Stable Placement

Scan right-to-left using cumulative prefix counts to place each element into its exact stable output slot in O(n + k).

Time Complexity: O(n + k)

Study the algorithm · Watch Visualizer · All Algorithm Games