@@ -0,0 +1,1079 @@
+/**%0A *%09Given an index k, return the kth row of the Pascal's triangle.%0A *%0A *%09For example, given k = 3,%0A *%09Return %5B1,3,3,1%5D.%0A *%0A *%09Note:%0A *%09Could you optimize your algorithm to use only O(k) extra space?%0A *%0A *%09Author: matao%0A *%0A */%0A%0Aimport java.util.List;%0Aimport java.util.ArrayList;%0A%0Apublic class PascalTriangleII %7B%0A%09public static List%3CInteger%3E getRow1(int rowIndex) %7B%0A        if(rowIndex %3C 0) %7B%0A        %09return null;%0A        %7D%0A        List%3CList%3CInteger%3E%3E total = new ArrayList%3CList%3CInteger%3E%3E();%0A        for (int i = 0; i %3C= rowIndex; i++) %7B%0A        %09List%3CInteger%3E item = new ArrayList%3CInteger%3E();%0A        %09for (int j = 0; j %3C= i; j++) %7B%0A        %09%09if(j == 0 %7C%7C j == i) %7B%0A        %09%09%09item.add(1);%0A        %09%09%7D else %7B%0A        %09%09%09item.add(total.get(i-1).get(j-1) + total.get(i-1).get(j));%0A        %09%09%7D%0A        %09%7D%0A        %09total.add(item);%0A        %7D%0A        return total.get(rowIndex);%0A    %7D%0A%0A    public static List%3CInteger%3E getRow2(int rowIndex) %7B%0A    %09%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A    %09System.out.println(getRow1(3));%0A    %09System.out.println(getRow2(3));%0A    %7D%0A%7D

add Pascal Triangle II solution