Python || Dynamic Programming || Simple Solution
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
```python3 []
class Solution:
    def minCost(self, n: int, cost: List[List[int]]) -> int:
        dp = [[[math.inf, math.inf, math.inf] for _ in range(3)] for _ in range(0, n // 2)]
        ind = (n // 2) - 1
        for i in range(3):
            for j in range(3):
                if i == j:
                    continue
                dp[-1][i][j] = cost[ind][i] + cost[(-ind - 1)][j]
        for i in range(ind - 1, -1, -1):
            for j in range(3):
                for k in range(3):
                    if j == k:
                        continue
                    mn = math.inf
                    for x in range(3):
                        if x == j:
                            continue
                        for y in range(3):
                            if k == y:
                                continue
                            mn = min(mn, dp[i + 1][x][y])
                    dp[i][j][k] = cost[i][j] + cost[(-i - 1)][k] + mn
        return min(min(i) for i in dp[0])
                
                                

        
```
['Array', 'Dynamic Programming', 'Python3']