You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
368 B

package class30;
import java.util.ArrayList;
import java.util.List;
public class Problem_0119_PascalTriangleII {
public List<Integer> getRow(int rowIndex) {
List<Integer> ans = new ArrayList<>();
for (int i = 0; i <= rowIndex; i++) {
for (int j = i - 1; j > 0; j--) {
ans.set(j, ans.get(j - 1) + ans.get(j));
}
ans.add(1);
}
return ans;
}
}