This commit is contained in:
2025-03-27 11:56:11 +08:00
parent 572479248d
commit c69a6b5ca9
3 changed files with 52 additions and 0 deletions

18
src/2712.c Normal file
View File

@@ -0,0 +1,18 @@
//
// Created by xfj12 on 2025/3/27.
//
#include <solution/2712.h>
#include <string.h>
#define min(a, b) (a < b) ? (a) : (b)
long long minimumCost(char *s)
{
int n = strlen(s);
long long ans = 0;
for (int i = 1; i < n; i++)
if (s[i] != s[i - 1])
ans += min(i, n - i);
return ans;
}