Is this O(1) space?


  • 0
    O
    enter code here
        if(triangle==null||triangle.size()==0) return 0;
        for(int i=triangle.size()-2;i>=0;i--){
            for(int j=0;j<triangle.get(i).size();j++){
                triangle.get(i).set(j, triangle.get(i).get(j)+Math.min(triangle.get(i+1).get(j), triangle.get(i+1).get(j+1)));
            }
        }
        return triangle.get(0).get(0);

Log in to reply
 

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