public ArrayList<Integer> getRow(int rowIndex) {
        //store the result
        ArrayList<Integer> a = new ArrayList<>();
        //store all the elements
        int[] b = new int[rowIndex + 1];

        if (rowIndex < 0) {
            return a;
        }
        //the rowIndex is 3, the b.size is 4
        for (int i = 0; i < rowIndex + 1; i++) {
            //every time the first will be 1
            b[0] = 1;
            //start from the second row
            if (i > 0) {
                //start from the third row
                //calculate from end to the begin, based on the change flow
                for (int j = i - 1; j > 0; j--) {
                    b[j] = b[j] + b[j - 1];
                }
                b[i] = 1;
            }
        }
        //set all into the list
        for (int i = 0; i < b.length; i++) {
            a.add(b[i]);
        }
        return a;
    }