2716
This commit is contained in:
26
src/2716.c
Normal file
26
src/2716.c
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user