Pascal's Triangle II

来源:互联网 发布:文件夹加密软件解密 编辑:程序博客网 时间:2024/04/28 20:07
public class Solution {    public List<Integer> getRow(int rowIndex) {        List<Integer> result = new ArrayList<Integer>();        if (rowIndex < 0) {            return result;        }        result.add(1);        for (int i = 0; i < rowIndex; i++) {            result.add(1);            for (int j = i; j > 0; j--) {                result.set(j, result.get(j) + result.get(j - 1));            }        }        return result;    }}

0 0