You are viewing a single comment's thread. Return to all comments →
Swift solution:
func rotateLeft(d: Int, arr: [Int]) -> [Int] { let n = arr.count // 'mod' operation avoids unnecessary rotations let rotations = d % n return Array(arr[rotations...] + arr[..<rotations]) }
Seems like cookies are disabled on this browser, please enable them to open this website
Left Rotation
You are viewing a single comment's thread. Return to all comments →
Swift solution: