This commit is contained in:
2025-07-21 18:14:17 +08:00
parent cb718130f7
commit b9a758a025
3 changed files with 93 additions and 0 deletions

30
src/1233.c Normal file
View File

@@ -0,0 +1,30 @@
#include <solution/1233.h>
#include <stdbool.h>
#include <stdlib.h>
bool startwith(char *p, char *s)
{
for (; *p && *s; p++, s++)
if (*p != *s)
return false;
return (!*p && *s) || (!*p && !*s);
}
char **removeSubfolders(char **folder, int folderSize, int *returnSize)
{
char **ret = malloc(sizeof(char *));
*returnSize = 1;
ret[0] = folder[0];
for (int i = 1; i < folderSize; i++)
{
if (startwith(ret[*(returnSize)-1], folder[i]))
continue;
ret = realloc(ret, sizeof(char *) * ++(*returnSize));
ret[*returnSize - 1] = folder[i];
}
return ret;
}