포스트

문자 반복 출력하기

https://school.programmers.co.kr/learn/courses/30/lessons/120825

문제

  • 문제 풀이
1
2
3
4
5
6
7
8
9
10
11
12
13
14
class Solution {
    public String solution(String my_string, int n) {
        StringBuilder result = new StringBuilder();

        for (int i = 0; i < my_string.length(); i++) {
            char currentChar = my_string.charAt(i);
            for (int j = 0; j < n; j++) {
                result.append(currentChar);
            }
        }

        return result.toString();
    }
}
이 기사는 저작권자의 CC BY 4.0 라이센스를 따릅니다.