119. Pascal's Triangle II

    /*
     * 119. Pascal's Triangle II 
     * 12.6 by Mingyang 
     * 注意list.set(index,value)是改变某一个index的value
     * 从后面往前加
     */
    public List<Integer> getRow(int rowIndex) {
        List<Integer> res = new ArrayList<Integer>();
        res.add(1);
        if (rowIndex == 0)
            return res;
        for (int j = 1; j < rowIndex + 1; j++) {
            res.add(1);
            for (int i = j - 1; i > 0; i--) {
                res.set(i, res.get(i - 1) + res.get(i));
            }
        }
        return res;
    }
原文地址:https://www.cnblogs.com/zmyvszk/p/5511563.html