Triangle Problem


  • 0
    R

    My code is marked as wrong for the following input:

    Input: [[-1],[2,3],[1,-1,-3]]
    Output: -2
    Expected: -1

    If I am not wrong, the correct answer should be -1+2+(-3)=-2.
    Any one can explain to me?


  • 1
    S
         -1
      [2]   3
    1    -1   -3
    

    Where you are at 2, it is impossible to move to -3, only 1 and -1 is available.


  • 0
    R

    Thanks for the reply. But Still I have doubt.
    [-1]
    [2] 3
    1 [-1] -3

    So the values chosen should be -1+2+(-1)=0. Am I wrong again?


  • 0
    S

    This problem is asking for minimum sum. In terms of this test case, the path is -1 + 3 + -3 = -1.


Log in to reply
 

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