Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- enumerate
- MAX
- Algorithm
- Sorted
- lambda
- LOWER
- count
- index
- decorator
- slice
- STR
- or
- sum
- DART
- js
- WECODE
- Python
- len
- range
- iNT
- 위코드
- If
- 파이썬
- and
- list
- FOR
- map
- SQL
- join
- split
Archives
- Today
- Total
코드로 우주평화
1203. String repeat 본문
Write a function that accepts an integer n and a string s as parameters, and returns a string of s repeated exactly n times.
Examples (input -> output)
6, "I" -> "IIIIII"
5, "Hello" -> "HelloHelloHelloHelloHello"
Solution:
String repeatString(int n, String s) {
String result = '';
for (int i=0; i<n; i++) {
result += s;
}
return result;
}
String repeatString(int n, String s) => s * n;
'나는 이렇게 학습한다 > Algorithm & SQL' 카테고리의 다른 글
1205. Sum of Cubes (0) | 2022.12.05 |
---|---|
1204. Odd or Even? (0) | 2022.12.04 |
1202. Count by X (0) | 2022.12.02 |
1201. Is the string uppercase? (0) | 2022.12.01 |
1130. Square(n) Sum (0) | 2022.11.30 |