You are viewing a single comment's thread. Return to all comments →
Hash map
int* icecreamParlor(int m, int arr_count, int* arr, int* result_count) { *result_count = 2; int* res = (int* )malloc((*result_count)*sizeof(int)); int* map = (int* )calloc(10001,sizeof(int)); for (int i = 0; i<arr_count; i++){ int temp = m-arr[i]; if (temp >= 0 && map[temp] != 0){ res[0] = map[temp]; res[1] = i+1; free(map); return res; } map[arr[i]] = i+1; } return NULL; }
Seems like cookies are disabled on this browser, please enable them to open this website
Ice Cream Parlor
You are viewing a single comment's thread. Return to all comments →
Hash map