229. 문자열 밀기

김해준's avatar
Jan 10, 2026
229. 문자열 밀기

사용언어 : Java

문제
notion image
풀이
class Solution { public int solution(String A, String B) { if(A.equals(B))return 0; int answer = -1; String temp = A; for(int i = 1 ; i <= A.length(); i++) { char tail = temp.charAt(A.length() - 1); temp = tail + temp.substring(0,A.length() - 1); if(temp.equals(B)) { answer = i; break; } } return answer; } }
notion image
Share article