简单的编程题,响应题目要求,不用额外的存储空间
public class Solution {
public ArrayList<Integer> getRow(int rowIndex) {
// Start typing your Java solution below
// DO NOT write main() function
ArrayList<Integer> result = new ArrayList<Integer>();
if (rowIndex < 0)
return result;
for (int i=0; i<=rowIndex; i++) {
result.add(1);
for (int j=result.size()-2; j>=0; j--) {
int value = result.get(j);
if (j > 0)
value += result.get(j-1);
result.set(j, value);
}
}
return result;
}
}