We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
int numberOfTest = int.Parse(Console.ReadLine());
for (int t = 0; t < numberOfTest; t++)
{
var s = Console.ReadLine().ToArray();
var ops = 0;
// Ignore the character in the middle, if any (it will automatically be excluded by the condition in the for-loop)
for (int i = 0, j = s.Length - 1; i < (s.Length / 2) && j >= (s.Length / 2); i++, j--)
ops += Math.Abs(s[j] - s[i]);
Console.WriteLine(ops.ToString());
}
}
The Love-Letter Mystery
You are viewing a single comment's thread. Return to all comments →
I tried my best in C#: