Arrays: Left Rotation

  • + 0 comments
    int n = a.size();
    std::vector<int> rotated_array(n);
    for (int i = 0; i < n; ++i) {
        rotated_array[i] = a[(i + d) % n];
    }
    return rotated_array;
    
        C++20