Swift로 백준 2675 문자열 반복 문제를 해결하며 얻은 지식을 정리합니다.
let numberOfInputs = Int(readLine()!)!
var inputs: [[String.SubSequence]] = []
func repeatCharacters(for input: [String.SubSequence]) {
let repeatingNumberForInput = Int(input[0])!
let splittedByCharacterOfInput = input[1].map { $0 }
var repeatedForInput: [Character] = []
splittedByCharacterOfInput.forEach {
for _ in 1...repeatingNumberForInput {
repeatedForInput.append($0)
}
}
print(String(repeatedForInput))
}
for _ in 1...numberOfInputs {
inputs.append(readLine()!.split(separator: " "))
}
for i in 0..<numberOfInputs {
repeatCharacters(for: inputs[i])
}