We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent caceb3c commit 31fab14Copy full SHA for 31fab14
1 file changed
ksinji/202511/16 PGM 조이스틱.md
@@ -0,0 +1,26 @@
1
+```java
2
+class Solution {
3
+ public int solution(String name) {
4
+ int answer = 0;
5
+
6
+ for (int i=0; i<name.length(); i++){
7
+ int diff = name.charAt(i)-'A';
8
+ answer += Math.min(diff, 26-diff);
9
+ }
10
11
+ int move = name.length()-1;
12
13
+ int next = i+1;
14
15
+ while (next<name.length() && name.charAt(next)=='A'){
16
+ next++;
17
18
19
+ move = Math.min(move, i*2+(name.length()-next));
20
+ move = Math.min(move, i+(name.length()-next)*2);
21
22
23
+ return answer+move;
24
25
+}
26
+```
0 commit comments