Simple C Solution, O(k)


  • 0
    A
    int* getRow(int rowIndex, int* returnSize) {
    	int i, j;
        int *result;
    	*returnSize = rowIndex+1;
    	result = (int *)malloc(sizeof(int) * (*returnSize));
    	for(i=0; i<(*returnSize); i++) {
    		*(result+i) = 1;
    		for(j=i-1; j>=1; j--) {
    		    *(result+j) += *(result+j-1);
    		}
    	}
    	return result;
    }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.