Subtraction game winner
Your task
Two players play with several heaps. From a single chosen heap a player may remove any amount that is in a fixed allowed set S of positive integers (the same S for all heaps). A player who cannot move loses. Given the heap sizes and the sorted allowed-removal set S, return true if the first player wins under optimal play. Constraints: 1 <= number of heaps <= 100, 0 <= each heap <= 10000, 1 <= |S| <= 100, elements of S are distinct positive integers.
Examples
subtraction_game_winner(heaps: list[int], S: list[int]) -> boolExample 1
Input
subtraction_game_winner([4], [2, 3])Output
True