classSolution:""" @param triangle: a list of lists of integers. @return: An integer, minimum path sum. """defminimumTotal(self,triangle):# write your code here# use triangle to store the min value# From bottom to topiftriangle==None:return0iflen(triangle)==1andlen(triangle[0])==1:returntriangle[0][0]row=len(triangle)foriinrange(row-2,-1,-1):forjinrange(len(triangle[i])):triangle[i][j]+=min(triangle[i+1][j],triangle[i+1][j+1])returntriangle[0][0]if__name__=="__main__":sol=Solution()printsol.minimumTotal([[2],[3,4],[6,5,7],[4,1,8,3]])