DP

```
class Solution {
public int minCost(int[][] costs) {
if (costs.length == 0) {
return 0;
}
int lastR = costs[0][0];
int lastB = costs[0][1];
int lastG = costs[0][2];
for (int i = 1; i < costs.length; i++) {
int curR = Mat953. Verifying an Alien Dictionary
h.min(lastB, lastG) + costs[i][0];
int curB = Math.min(lastR, lastG) + costs[i][1];
int curG = Math.min(lastR, lastB) + costs[i][2];
lastR = curR;
lastB = curB;
lastG = curG;
}
return Math.min(lastR, Math.min(lastB, lastG));
}
}
```