@@ -0,0 +1,1422 @@
+// Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.%0A%0A// For example, given the following triangle%0A// %5B%0A//      %5B2%5D,%0A//     %5B3,4%5D,%0A//    %5B6,5,7%5D,%0A//   %5B4,1,8,3%5D%0A// %5D%0A// The minimum path sum from top to bottom is 11 (i.e., 2 + 3 + 5 + 1 = 11).%0A%0A// Note:%0A// Bonus point if you are able to do this using only O(n) extra space, where n is the total number of rows in the triangle.%0A%0Apublic class Solution %7B%0A    public int minimumTotal(List%3CList%3CInteger%3E%3E triangle) %7B%0A        if(triangle == null %7C%7C triangle.size() == 0) return 0;%0A%0A        int level = triangle.size();%0A%0A        for(int i = 1; i %3C level; i++)%7B%0A        %09List%3CInteger%3E previous = triangle.get(i - 1);%0A        %09List%3CInteger%3E current = triangle.get(i);%0A%0A        %09for(int j = 0; j %3C current.size(); j++)%7B%0A        %09%09if(j == 0)%7B%0A        %09%09%09current.set(j, previous.get(0) + current.get(j));%0A        %09%09%7Delse if(j == current.size() - 1)%7B%0A        %09%09%09current.set(j, current.get(j) + previous.get(previous.size() - 1));%0A        %09%09%7Delse%7B%0A%09        %09%09int left = previous.get(j - 1);%0A%09        %09%09int right = previous.get(j);%0A%0A%09        %09%09current.set(j, left %3E right? right + current.get(j) : left + current.get(j));%09%0A        %09%09%7D%0A        %09%7D%0A        %7D%0A%0A        int min = Integer.MAX_VALUE;%0A%0A        for(int i : triangle.get(level - 1))%7B%0A        %09min = min %3E i? i : min;%0A        %7D%0A%0A        return min;%0A    %7D%0A%7D

add triangle solution