public static List<Integer> getRow(int rowIndex) {//AC at first attempt!
        int[][] t = new int[2][rowIndex+1];
        for (int i = 0; i <= rowIndex; ++i) {
            if (i % 2 == 0) {
                if (i == 0) {
                    t[0][0] = 1;
                }
                else {
                    t[0][0] = 1;
                    t[0][i] = 1;
                    for (int j = 1; j < i; ++j) {
                        t[0][j] = t[1][j] + t[1][j-1];
                    }
                }
            }
            else {
                t[1][0] = 1;
                t[1][i] = 1;
                for (int j = 1; j < i; ++j) {
                    t[1][j] = t[0][j] + t[0][j-1];
                }
            }
        }
        int index_of_t = (rowIndex) % 2;
        ArrayList<Integer> ret = new ArrayList<Integer>();
        for (int k = 0; k <= rowIndex; ++k) {
            ret.add(t[index_of_t][k]);
        }
        return ret;
    }