Python "Hard Code" O(1) Solution


  • 0
    class Solution(object):
        def flipLights(self, n, m):
            if m == 0 or n == 0:
                return 1
            if n == 1:
                return 2
            if n == 2:
                if m == 1:
                    return 3
                return 4
            if n > 2:
                if m == 1:
                    return 4
                elif m == 2:
                    return 7
                return 8
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.