[스위프트] (1, 3, 4, 5) timeOut이 발생합니다. - goormEDU

Q&A

It is a place to ask and answer questions related to IT technology.

0
[스위프트] (1, 3, 4, 5) timeOut이 발생합니다.
profileinteractord
03/04/21, 07:33 PM
Question Path :
import Foundation let MAX_TABLE_COUNT = 1_000_000 let fib: [Int] = { var table: [Int] = (0...MAX_TABLE_COUNT+1).map { _ in 0 } table[1] = 0 table[2] = 1 (3...MAX_TABLE_COUNT).forEach { i in table[i] = (table[i-1] + table[i-2]) % 100_000_000 } return table }() func solve(numberList: [Int]) { let result = numberList.map { "\(fib[$0])" }.joined(separator: "\n") print(result) } let numberList: [Int] = Array(repeating: "", count: Int(readLine()!)!).map { _ in Int(readLine()!)! } solve(numberList: numberList)

깃헙에 답안을 보고 스위프트로 만들어봤는데... 타임아웃이 나더라구요.. 혹시 다른 해결방안이 있을까요?