why runtime error


  • 0
    S

    int** subsets(int* nums, int numsSize, int** columnSizes, int* returnSize) {
    int mark = 0;
    int i = 0;
    int nStart = 0;
    int nEnd = (1 << numsSize) - 1;
    int ct;
    int ** result;
    bool bNullSet = false;

    *returnSize = nEnd+1;
    *columnSizes = (int*)malloc(sizeof(int)*nEnd);
    result = (int**)malloc(sizeof(int*)*nEnd);
    
    for (mark = nStart; mark <= nEnd; mark++)
    {
    	bNullSet = true;
    	ct = 0;
    	for (i = 0; i < numsSize; i++)
    	{
    		if (((1 << i)&mark) != 0)
    		{
    			bNullSet = false;
    			ct = ct + 1;
    		}
    	}
    	(*columnSizes)[mark] = ct;
    	result[mark]= (int*)malloc(sizeof(int)*ct);
    	ct = 0;
    	for (i = 0; i < numsSize; i++)
    	{
    		if (((1 << i)&mark) != 0)
    		{
    			result[mark][ct] = nums[i];
    			ct = ct + 1;
    		}
    	}
    
    	if (bNullSet) 
    	{
    		result[mark] = NULL;
    	}
    }
    return result;
    

    }

    this is my code , it can work in my computer , but runtime error here


Log in to reply
 

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