Skip to content

Instantly share code, notes, and snippets.

@halirutan
Created October 14, 2020 21:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save halirutan/58c5d17435d15d26fc818b7b0e6f2e41 to your computer and use it in GitHub Desktop.
Save halirutan/58c5d17435d15d26fc818b7b0e6f2e41 to your computer and use it in GitHub Desktop.
#include <stdlib.h>
/**
* Return an array of arrays of size *returnSize.
* The sizes of the arrays are returned as *returnColumnSizes array.
* Note: Both returned array and *columnSizes array must be malloced, assume caller calls free().
*/
int** threeSum(int* nums, int numsSize, int* returnSize, int** returnColumnSizes){
*returnSize = 1;
*returnColumnSizes = (int*) malloc(1* sizeof(int));
*returnColumnSizes[0] = 3;
int **result = (int **) malloc(1 * sizeof(int *));
int *sol1 = (int *) malloc(3* sizeof(int));
sol1[0] = 1;
sol1[1] = 2;
sol1[2] = 3;
result[0] = sol1;
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment