@@ -0,0 +1,1143 @@
+package leetcode;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0A/**%0A * https://oj.leetcode.com/problems/pascals-triangle/%0A */%0Apublic class Problem118 %7B%0A    public List%3CList%3CInteger%3E%3E generate(int numRows) %7B%0A        List%3CList%3CInteger%3E%3E result = new ArrayList%3C%3E();%0A        if (numRows == 0) %7B%0A            return result;%0A        %7D%0A        List%3CInteger%3E list = new ArrayList%3C%3E();%0A        list.add(1);%0A        result.add(list);%0A        pascalsTriangle(numRows, 1, result);%0A        return result;%0A    %7D%0A    %0A    private void pascalsTriangle(int numRows, int n, List%3CList%3CInteger%3E%3E result) %7B%0A        if (n %3E= numRows) %7B%0A            return;%0A        %7D%0A        List%3CInteger%3E prevList = (result.size() == 0) ?%0A            new ArrayList%3CInteger%3E() : result.get(result.size()-1);%0A        List%3CInteger%3E currentList = new ArrayList%3C%3E();%0A        currentList.add(1);%0A        for (int i = 0; i %3C prevList.size()-1; i++) %7B%0A            int value = prevList.get(i) + prevList.get(i+1);%0A            currentList.add(value);%0A        %7D%0A        currentList.add(1);%0A        result.add(currentList);%0A        %0A        pascalsTriangle(numRows, n+1, result);%0A    %7D%0A%7D%0A

Solve problem 118