public func solution(_ A : inout [Int], _ K : Int) -> [Int] {
let rotations: Int = K % A.count
if K == 0 || A.isEmpty || rotations == 0 {
return A
}
var firstPart: [Int] = [], secondPart: [Int] = []
for i in 0..<A.count {
if i < (A.count - rotations) {
secondPart.append(A[i])
} else {
firstPart.append(A[i])
}
}
return firstPart + secondPart
}