Pascal's Triangle II
ID: 119; easy
Last updated
class Solution {
public List<Integer> getRow(int rowIndex) {
List<Integer> ans = new ArrayList<>();
ans.add(1);
long curElement = 1;
for (int i = 1; i <= rowIndex; i++) {
curElement = curElement * (rowIndex-i+1) / i;
ans.add((int)curElement);
}
return ans;
}
}