No idea whats wrong in this python solution ?


  • 0
    V

    class Solution(object):
    def minimumTotal(self, triangle):
    """
    :type triangle: List[List[int]]
    :rtype: int
    """
    a = []
    b = min(triangle[0])
    a.append(b)
    c = triangle[0].index(b)

        for i in triangle[1:]:
            
            print i[c], i [c+1]
            if i[c] > i [c+1]:
                
                a.append(i[c+1])
                print a 
                d = c+1
            else:
                a.append(i[c])
                print a 
                d = c
            c = d
        return sum(a)

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.