class Solution:
# @param {int[][]} costs n x 3 cost matrix
# @return {int} an integer, the minimum cost to paint all houses
def minCost(self, costs):
# Write your code here
if len(costs) == 0:
return 0
record = costs[0]
for cost in costs[1:]:
temp = []
for i in range(len(cost)):
temp.append(cost[i]+min(record[i-1],record[i-2]))
record = temp
return min(record)