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