
문제를 이해하고 있다면 바로 풀이를 보면 됨
전체 코드로 바로 넘어가도 됨
마음대로 번역해서 오역이 있을 수 있음
영어 소문자 'a'부터 'z'까지 원형으로 배열되어 있고 포인터가 달린 특수한 타자기가 있다. 특정 문자는 포인터가 해당 문자를 가리키고 있을 때만 입력할 수 있다. 포인터는 처음에 'a'를 가리키고 있다.

초마다 다음 작업 중 하나를 수행할 수 있다.
문자열 word가 주어졌을 때, word에 있는 문자를 입력하는데 걸리는 최소한의 시간을 반환해라.
#1
Input: word = "abc"
Output: 5
#2
Input: word = "bza"
Output: 7
#3
Input: word = "zjpc"
Output: 34
class Solution {
public int minTimeToType(String word) {
int result = 0;
char pointer = 'a';
for(char c : word.toCharArray()){
int clockwise = Math.abs(c - pointer);
int counterclockwise = 26 - clockwise;
result += Math.min(clockwise, counterclockwise) + 1;
pointer = c;
}
return result;
}
}