1
# Runtime: 30 ms (Top 97.1%) | Memory: 16.43 MB (Top 14.4%)5
def flipLights(self, n: int, m: int) -> int:6
# Reduce n to at most 3, since any action performed more than 3 times7
# will result in a pattern that has already been counted12
# For m=1, there are only 2 outcomes for n=1, 3 outcomes for n=2, and 4 outcomes for n=313
return [2, 3, 4][n - 1]15
# For m=2, there are only 2 outcomes for n=1, 4 outcomes for n=2, and 7 outcomes for n=316
return [2, 4, 7][n - 1]18
# For m>=3, there are only 2 outcomes for n=1, 4 outcomes for n=2, and 8 outcomes for n=319
return [2, 4, 8][n - 1]