Subtraction Game {2,4,6} — Solution & Editorial
Compute Grundy numbers by the mex of reachable positions, then XOR them (Sprague–Grundy).
Complexity: O(max · |moves| + K)
Compute Grundy numbers by the mex of reachable positions, then XOR them (Sprague–Grundy).
Complexity: O(max · |moves| + K)