[프로그래머스] 문자열 곱하기

Seah Lee·2023년 6월 18일
0

프로그래머스

목록 보기
6/57

class Solution {
    public String solution(String my_string, int k) {
        
        StringBuilder sb = new StringBuilder();
        for (int i=0;i<k;i++){
            sb.append(my_string);
        }
        
        return sb.toString();
    }
}

[다른 사람 풀이]

class Solution {
    public String solution(String my_string, int k) {
        return my_string.repeat(k);
    }
}

my_string.repeat(k) 하면 k번만큼 my_string 반복... 천재적이다

profile
성장하는 개발자

0개의 댓글