package leetcode;

/**
 * https://leetcode.com/problems/minimum-time-to-type-word-using-special-typewriter/
 */
public class Problem1974 {
    public int minTimeToType(String word) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem1974 prob = new Problem1974();
        System.out.println(prob.minTimeToType("abc")); // 5
        System.out.println(prob.minTimeToType("bza")); // 7
        System.out.println(prob.minTimeToType("zjpc")); // 34
    }
}

@@ -188,313 +188,340 @@
     
-// TODO%0A        return 0
+int answer = 0;%0A        int s = 'a'
 ;%0A    
-%7D%0A%0A
     
-public static void main(String%5B%5D args) %7B%0A        Problem1974 prob = new Problem1974();%0A        System.out.println(prob.minTimeToType(%22abc%22)); // 5%0A        System.out.println(prob.minTimeToType(%22bza%22)); // 7%0A        System.out.println(prob.minTimeToType(%22zjpc%22)); // 34
+for (char c : word.toCharArray()) %7B%0A            int diff1 = Math.abs(c - s);%0A            int diff2 = Math.abs(s + 26 - c);%0A            int diff3 = Math.abs(c + 26 - s);%0A            answer += Math.min(diff1, Math.min(diff2, diff3)) + 1;%0A            s = c;%0A        %7D%0A        return answer;
 %0A   

Solve problem 1974