This commit is contained in:
2025-03-28 20:56:16 +08:00
parent c69a6b5ca9
commit 5f09521d43
3 changed files with 75 additions and 0 deletions

26
src/2716.c Normal file
View File

@@ -0,0 +1,26 @@
//
// Created by xfj12 on 2025/3/28.
//
#include <solution/2716.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
int minimizedStringLength(char *s)
{
int n = strlen(s);
int size = 0;
char *temp = malloc(n);
for (int i = 0; i < n; i++)
{
bool flag = true;
for (int j = 0; j < size && flag; j++)
if (s[i] == temp[j])
flag = false;
if (flag)
temp[size++] = s[i];
}
free(temp);
return size;
}