Easy DP Approach || CPP
IntuitionApproachJust Decide At each index what can be the color for the current index and n-ind-1 th index based on the prev left and prev right valComplexity
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->
Just Decide At each index what can be the color for the current index and n-ind-1 th index based on the prev left and prev right val
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

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

# Code
```cpp []
class Solution {
public:
    using ll = long long;
    ll rec(int ind,vector<vector<int>>& cost,int left,int right,int n,vector<vector<vector<ll>>>&dp){
        if(ind >= n/2)return 0;
        if(dp[ind][left][right] != -1)return dp[ind][left][right];
        ll mini = 1e18;
        for(int i=1; i<=3; i++){
            ll temp = 0;
            if(i != left){
                ll x1 = i,x2 = right;
                for(int j=1; j<=3; j++){
                    if(j != x1 && j != x2){
                        mini = min(mini,ll(cost[ind][i-1]+cost[n-ind-1][j-1])+rec(ind+1,cost,i,j,n,dp));
                    }
                }
            }
        }
        return dp[ind][left][right] = mini;
    }
    long long minCost(int n, vector<vector<int>>& cost) {
        vector<vector<vector<ll>>>dp((n/2)+1,vector<vector<ll>>(4,vector<ll>(4,-1)));
        return rec(0,cost,0,0,n,dp);
    }
};
```
['C++']