๐ฌย ๋ฌธ์
https://app.codility.com/programmers/lessons/2-arrays/cyclic_rotation/
๐ฌย Idea
- K๋ฒ์ ๋๋ฉด์ ๋ฐฐ์ด A์ ๋ง์ง๋ง ์์๋ฅผ ์ถ์ถํ๊ณ , ์ฒซ๋ฒ์งธ์ ๊ทธ ์์๋ฅผ ์ง์ด๋ฃ๋๊ฒ์ ๋ฐ๋ณตํ์
- ์ฃผ์! ๋น ๋ฐฐ์ด ๋ฐํ์ ์ค๋ฅ ์ฃผ์
๐ฌย ํ์ด
import Foundation
publicfunc solution(A:inout[Int], K:Int)->[Int]{ifA.isEmpty {return[]}for_in0..<K {A.insert(A.removeLast(), at:0)}return A
}
๐ฌย ๋ฌธ์ https://app.codility.com/programmers/lessons/2-arrays/cyclic_rotation/
๐ฌย Idea๐ฌย ํ์ด