-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Labels
Description
๐ฌย ๋ฌธ์
https://app.codility.com/programmers/lessons/2-arrays/cyclic_rotation/
๐ฌย Idea
- K๋ฒ์ ๋๋ฉด์ ๋ฐฐ์ด A์ ๋ง์ง๋ง ์์๋ฅผ ์ถ์ถํ๊ณ , ์ฒซ๋ฒ์งธ์ ๊ทธ ์์๋ฅผ ์ง์ด๋ฃ๋๊ฒ์ ๋ฐ๋ณตํ์
- ์ฃผ์! ๋น ๋ฐฐ์ด ๋ฐํ์ ์ค๋ฅ ์ฃผ์
๐ฌย ํ์ด
import Foundation
public func solution(A: inout [Int], K: Int) -> [Int] {
if A.isEmpty { return [] }
for _ in 0..<K {
A.insert(A.removeLast(), at: 0)
}
return A
}