We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • Practice
  • Certification
  • Compete
  • Career Fair
  • Hiring developers?
  1. Practice
  2. Tutorials
  3. Cracking the Coding Interview
  4. Arrays: Left Rotation
  5. Discussions

Arrays: Left Rotation

Problem
Submissions
Leaderboard
Discussions
Editorial

    You are viewing a single comment's thread. Return to all comments →

  • domar 4 years ago+ 0 comments

    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.

    0|
    ParentPermalink
  • Contest Calendar
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature