vector<int> shortestToChar(string S, char C) {
vector<int> V; const int N = ;
int AYC[N];
int countC = ;
for (int i = ; i < S.size(); i++)
{
if (S[i] == C)
{
AYC[countC] = i;
countC++;
}
}
for (int i = ; i < S.size(); i++)
{
int min = INT_MAX;
for (int j = ; j < countC; j++)
{
int dif = abs(i - AYC[j]);
if (dif < min)
{
min = dif;
}
}
V.push_back(min);
}
return V;
}
05-11 17:15