def minCostII(self, costs):
        if not costs:
            return 0

        n = len(costs)
        m = len(costs[0])
        F = [[0 for _ in xrange(m)] for _ in xrange(n+1)]
        for i in xrange(1, n+1):
            for k1 in xrange(m):
                F[i][k1] = min(
                    F[i-1][k0]+costs[i-1][k1]
                    # if i == 1 or k1 != k0 else sys.maxint  # another syntax 
                    for k0 in xrange(m)
                    if i == 1 or k1 != k0
                )

        return min(F[n][i] for i in xrange(m))
Lef F[i][j] be the total min costs when the houses BEFORE i are painted, with (i-1)-th house pained as color j
dataset/ETHPy150Open algorhythms/LeetCode/265 Paint House II.py/Solution.minCostII