I have a problem. I give it string "BC"
and it outputs 54 not 55
as in first cycle num = 3
and in second num = 52
but the sum is 54
why?
Can you help me?
string getX(string x) {
int ans = 0, num;
for (int i = 0, j = x.size() - 1; i < x.size(), j >= 0; i++, j--) {
num = x[j] - 64;
num = num * pow(26, i);
ans += num;
}
return to_string(ans);
}