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.
Loading...
  • Practice
  • Compete
  • Jobs
  • Leaderboard
  1. Practice
  2. Data Structures
  3. Arrays
  4. Left Rotation
  5. Discussions

Left Rotation

  • Problem
  • Submissions
  • Leaderboard
  • Discussions
  • Editorial

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

  • limpingandroid 3 months ago+ 0 comments

    I saw this was different than the other problems. Yes, I put it in the bottom of main, using n, d and a.

    Are you using C? There appears to be a bug in the original code. This is my fix to their problem:

        // bug in original code - only check endptr if we need to do another loop
        //      if (a_item_endptr == a_item_str || *a_item_endptr != '\0') { exit(EXIT_FAILURE); }
        if (a_item_endptr == a_item_str) { exit(EXIT_FAILURE); }
    
        if (i < (n-1))
        {
            if (*a_item_endptr != '\0') { exit(EXIT_FAILURE); }
        }
        *(a + i) = a_item;
    
    0|
    ParentPermalink
  • Contest Calendar
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature