Given n balls with initial positions, all white; after each step, balls on marked positions flip (white to black or black to white) and every position advances by 1 (e.g. N=5, marked positions [1,3]). Write a step_k function with O(n) time complexity.
The technical phone screen uses five cyclic positions, numbered 0 through 4. At each step, determine which balls currently occupy a marked position, flip those balls, then advance every ball by one position modulo 5.
Implement step_k(initial_positions, marked_positions, k). Return a list aligned with initial_positions, where each item is [final_position, final_color]. Every ball starts white, and k may be zero or very large.
def step_k(initial_positions, marked_positions, k):