class Solution(object):
    def minimumTotal(self, triangle):
        """
        :type triangle: List[List[int]]
        :rtype: int
        """
        n=len(triangle)
        if n==0:
            return 0
        res=triangle[-1]
        for i in range(n-2,-1,-1):
            for j in range(len(triangle[i])):
                res[j]=min(res[j],res[j+1])+triangle[i][j]
        return res[0]
s=Solution()
s.minimumTotal(root)
recursive RTLE
采用from bottom to top的方法
"""
class Solution(object):
    def minimumTotal(self, triangle):
        def helper(temp_sum,triangle,i,level):
            if level==n-1:
                return temp_sum
            return min(helper(temp_sum+triangle[level+1][i],triangle,i,level+1),helper(temp_sum+triangle[level+1][i+1],triangle,i+1,level+1))
        n=len(triangle)
        if n==0:
            return 0
        sum1=helper(triangle[0][0],triangle,0,0)
        return sum1
"""