java dp 
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```java []
class Solution {
    public long minCost(int n, int[][] cost) {

        // 가운데 부터 시작해서 짝이되는 두 집씩 칠해나아가면된다.

        long dp[][][] = new long[n][3][3];

        for(int i = n/2; i < n; i++) {
            for(int j = 0; j < 3; j++) {
                for(int k = 0; k < 3; k++) {
                    dp[i][j][k] = Long.MAX_VALUE;
                }
            }
        }


        for(int i = n/2; i < dp.length; i++) {
            
            for(int j = 0; j < 3; j++) {
                for(int k = 0; k < 3; k++) {
                    if ( j == k ) continue;
                    for(int a = 0; a < 3; a++) {
                        for(int b = 0; b < 3; b++) {
                            if ( a == b ) continue;
                            if ( a == j || b == k ) continue;
                            if (  dp[i-1][a][b] == Long.MAX_VALUE) continue;
                            dp[i][j][k] = Math.min(dp[i][j][k], dp[i-1][a][b] + cost[i][j] + cost[n-(i+1)][k]);
                            
                        }
                    }
                }
                
            }   
        }

        

        long result = Long.MAX_VALUE;
        for(int i = 0; i <3; i++) for(int j = 0; j <3; j++) result= Math.min(result, dp[n-1][i][j]);
        
        return result;
    }
}

```
['Dynamic Programming', 'Java']