# Problem

By
blackntt

link: https://www.hackerrank.com/challenges/ctci-array-left-rotation/problem

# Solution

/ Complete the rotLeft function below.
vector<int> rotLeft(vector<int> a, int d) {
    vector<int> rotArr(a.size(),0);
    for(size_t i = 0; i < a.size(); i++){
        int newIndex = i - d;
        if (newIndex < 0) {
            newIndex = a.size() + newIndex;
        }
        rotArr[newIndex] = a[i];
    }
    return rotArr;
}