```
public class Solution {// standing in front of each house, I have three options. in the end I just chose last cost options.
public int minCost(int[][] costs) {
if(costs.length==0)
return 0;
int paintR=costs[0][0];// if i chose paint red
int paintB=costs[0][1];
int paintG=costs[0][2];
int temp;
int temp1;
for(int i=1; i<costs.length;i++){
temp=paintR;
temp1=paintB;
paintR=costs[i][0]+Math.min(paintB,paintG);
paintB=costs[i][1]+Math.min(temp,paintG);
paintG=costs[i][2]+Math.min(temp1,temp);
}
return Math.min(Math.min(paintR,paintB), paintG);
}
```

}