char *handle_var_set(char ***keys, char ***values, char *key, char *value) { int tmp; if (key == NULL || value == NULL) return (NULL); if ((tmp = search_key_values((*keys), (*values), key)) != -1) { ft_strdel(&(*keys)[tmp]); ft_strdel(&(*values)[tmp]); (*keys)[tmp] = ft_strdup(key); (*values)[tmp] = ft_strdup(value); return (key); } if (insert_arr(&(*keys), key) == -1 || insert_arr(&(*values), value) == -1) return (NULL); return (key); }
int getkth_ksort(int k, int *arr, int size) { int i, j; bubblesort(arr, k); int *karr = (int *)malloc(sizeof(int) * k); for (j=0; j<k; j++) karr[j] = arr[j]; for (i=k; i<size; i++) { if (karr[k-1] < arr[i]) insert_arr(karr, k, arr[i]); } return karr[k-1]; }