Simple Python solution in O(n) time and O(1) space


#1
def solve(self, A):
    #A list[list[int]]
    n = len(A)
    if n == 0:
        return 0
        
    for i in range(1, n):
        A[i][0] += min(A[i-1][1], A[i-1][2])
        A[i][1] += min(A[i-1][0], A[i-1][2])
        A[i][2] += min(A[i-1][0], A[i-1][1])
    return min(A[-1])