• + 0 comments

    Concise O(n) Python solution using slicing

    def rotateLeft(d, arr):
        effective_d = d % len(arr)
        if len(arr) == 1 or effective_d == len(arr):
            return arr
            
        arr = arr[effective_d:] + arr[:effective_d]
            
        return arr