Last updated 3 years ago
Was this helpful?
time: O(n^2)
space: O(n)
same as 118, just return last row
class Solution { public List<Integer> getRow(int rowIndex) { List<Integer> list = new ArrayList<>(); for (int i = 0; i <= rowIndex; i++) { list.add(0,1); for (int j = 1; j < list.size() - 1; j++) { list.set(j, list.get(j)+list.get(j+1)); } } return list; } }