49.87 %
class Solution {
public List<Integer> getRow(int rowIndex) {
List<Integer> result = new ArrayList<>();
if (rowIndex < 0) return result;
for (int x = 0; x <= rowIndex; x++) {
result.add(1);
for (int y = x - 1; y > 0; y--) {
result.set(y, result.get(y) + result.get(y - 1));
}
}
return result;
}
}
No comments:
Post a Comment