Problem Statement
Konnectogrow has invented a new type of printing technology—a circular printer that looks like below
It is a circular printer wheel with the letters A through Z in sequence. It wraps so A and Z are adjacent. The printer has a pointer that is initially at ‘A’. Moving from any character to any adjacent character takes 1 second. It can move in either direction. Given a string of letters, what is the minimum time needed to print the string? (Note: Assume that printing does not take any time. Only consider the time it takes for the pointer to move.)
Example
s = “BZA”
First, move the pointer from ‘A’ to ‘B’ (1 second), then from ‘B’ to ‘Z’ (2 seconds), and finally from ‘Z’ to ‘A’ (1 second). So the minimum time needed to print “BZA” is 4 seconds.
Function Description
Complete the function getTime in your code
getTime has the following parameter:
string s: the string of characters that need to be printed
Returns:
int: the minimum number of seconds needed to print s
Constraints
- 1 ≤ length of s ≤ 105
Please do not hardcode any value in the code