公式推导,时间复杂度O(rowIndex),空间复杂度O(1)
/**
* Note: The returned array must be malloced, assume caller calls free().
*/
int* getRow(int rowIndex, int* returnSize){
int* nums = malloc(sizeof(int) * (rowIndex + 1));
nums[0] = 1;
nums[rowIndex] = 1;
for(int i = 1; i < rowIndex;++i){
nums[i] = 1LL * nums[i-1] * (rowIndex - i + 1) / i;
}
*returnSize = rowIndex + 1;
return nums;
}