2164 카드2

Choong Won, Seo·2021년 12월 28일
0

백준

목록 보기
8/28
post-thumbnail

Today 12/29

카드2 (My Code)

var inputArr = [Int]()
for index in 1...Int(readLine()!)! {
    inputArr.append(index)
}
var index = 0

while true {
    if inputArr.count == 1 {
        print("1")
        break
    }
    index += 1
    if index == inputArr.count-1 {
        print(inputArr[index])
        break
    }
    inputArr.append(inputArr[index])
    index += 1
}

FIFO의 Queue문제이다. 시간을 빠르게 하기 위해 버리는 카드를 직접 버리지 않고, index만 옮겨서 풀었다.

profile
UXUI Design Based IOS Developer

0개의 댓글