Leetcode 672 Solution

This article provides solution to leetcode question 672 (bulb-switcher-ii)

https://leetcode.com/problems/bulb-switcher-ii

Solution

class Solution:
    def flipLights(self, n: int, m: int) -> int:
        if n == 0:
            return 0

        if n == 1:
            if m == 0:
                return 1
            else:
                return 2

        if n == 2:
            if m == 0:
                return 1
            elif m == 1:
                return 3
            else:
                return 4

        if n >= 3:
            if m == 0:
                return 1
            elif m == 1:
                return 4
            elif m == 2:
                return 7
            else:
                return 8