Triangle test case output


  • 1
    H

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

    So, I have a problem with the output. My output is -2 and its expected -1.
    However, if I look at the input, the sum is -1 + 2 + -3 = -2.

    public class Solution {
    public int minimumTotal(ArrayList<ArrayList<Integer>> triangle) {
        int sum = 0;
    
    	for (ArrayList<Integer> row : triangle) {
    		sum += Collections.min(row);
    	}
    
    	return sum;
    }
    

    }


  • 0
    T

    This post is closed as Solved, but I didn't see any answer.
    Did I miss anything?


  • 0
    N

    I came into the same situation....
    no clue


  • 0
    Z

    the problem says "adjacent numbers on the row below", -3 is not adjacent number of 2 (only 1 and -1).


  • 0
    A

    @zihan in this case -1+2+(-1)=0? Why output-2?


Log in to reply
 

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