Python Solution o(1) space o(n) runtime EZ & Readable


  • 0
    D
    class Solution(object):
        def minimumTotal(self, triangle):
            for r in range(len(triangle)-2, -1, -1):
                for c in range(len(triangle[r])):
                    triangle[r][c] += min(triangle[r+1][c], 
                          triangle[r+1][c+1])
            return triangle[0][0]
    

Log in to reply
 

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