You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<p>문자열 "hello"에서 각 문자를 오른쪽으로 한 칸씩 밀고 마지막 문자는 맨 앞으로 이동시키면 "ohell"이 됩니다. 이것을 문자열을 민다고 정의한다면 문자열 <code>A</code>와 <code>B</code>가 매개변수로 주어질 때, <code>A</code>를 밀어서 <code>B</code>가 될 수 있다면 밀어야 하는 최소 횟수를 return하고 밀어서 <code>B</code>가 될 수 없으면 -1을 return 하도록 solution 함수를 완성해보세요.</p>
24
+
25
+
<hr>
26
+
27
+
<h5>제한사항</h5>
28
+
29
+
<ul>
30
+
<li>0 < <code>A</code>의 길이 = <code>B</code>의 길이 < 100</li>
31
+
<li><code>A</code>, <code>B</code>는 알파벳 소문자로 이루어져 있습니다.</li>
32
+
</ul>
33
+
34
+
<hr>
35
+
36
+
<h5>입출력 예</h5>
37
+
<tableclass="table">
38
+
<thead><tr>
39
+
<th>A</th>
40
+
<th>B</th>
41
+
<th>result</th>
42
+
</tr>
43
+
</thead>
44
+
<tbody><tr>
45
+
<td>"hello"</td>
46
+
<td>"ohell"</td>
47
+
<td>1</td>
48
+
</tr>
49
+
<tr>
50
+
<td>"apple"</td>
51
+
<td>"elppa"</td>
52
+
<td>-1</td>
53
+
</tr>
54
+
<tr>
55
+
<td>"atat"</td>
56
+
<td>"tata"</td>
57
+
<td>1</td>
58
+
</tr>
59
+
<tr>
60
+
<td>"abc"</td>
61
+
<td>"abc"</td>
62
+
<td>0</td>
63
+
</tr>
64
+
</tbody>
65
+
</table>
66
+
<hr>
67
+
68
+
<h5>입출력 예 설명</h5>
69
+
70
+
<p>입출력 예 #1</p>
71
+
72
+
<ul>
73
+
<li>"hello"를 오른쪽으로 한 칸 밀면 "ohell"가 됩니다.</li>
74
+
</ul>
75
+
76
+
<p>입출력 예 #2</p>
77
+
78
+
<ul>
79
+
<li>"apple"은 몇 번을 밀어도 "elppa"가 될 수 없습니다.</li>
80
+
</ul>
81
+
82
+
<p>입출력 예 #3</p>
83
+
84
+
<ul>
85
+
<li>"atat"는 오른쪽으로 한 칸, 세 칸을 밀면 "tata"가 되므로 최소 횟수인 1을 반환합니다.</li>
86
+
</ul>
87
+
88
+
<p>입출력 예 #4</p>
89
+
90
+
<ul>
91
+
<li>"abc"는 밀지 않아도 "abc"이므로 0을 반환합니다.</li>
92
+
</ul>
93
+
94
+
<hr>
95
+
96
+
<p>※ 공지 - 2023년 4월 24일 테스트케이스가 추가되었습니다. 기존에 제출한 코드가 통과하지 못할 수도 있습니다.</p>
97
+
98
+
99
+
> 출처: 프로그래머스 코딩 테스트 연습, https://school.programmers.co.kr/learn/challenges
0 commit comments