Arrays: Left Rotation

  • + 1 comment

    Pretty smart, but are you sure you are not copying the kth eleement, in ruby it would be:

    def array_left_rotation(a, k)
      a[k..-1] + a[0...k]
    end
    

    In ruby, ... means excluding the right number.