You are viewing a single comment's thread. Return to all comments →
Here's a O(n/2) solution in python:
T = int(input().strip()) for _ in range(T): str_ = str(input().strip()) ops = 0 for i in range(len(str_) // 2): ops += abs(ord(str_[i]) - ord(str_[-(i+1)])) print(ops)
Seems like cookies are disabled on this browser, please enable them to open this website
The Love-Letter Mystery
You are viewing a single comment's thread. Return to all comments →
Here's a O(n/2) solution in python: