C++ Solution Array Bug solution


#1

vector Solution::rotateArray(vector &A, int B) {
vector ret;
int limit;
if(B>A.size()){
if(B%A.size()==0)
{
limit=0;
}
else
{
limit= B%A.size();
}
}
else{
limit=B;
}
for (int i = 0;i+limit<A.size(); i++) {

   ret.push_back(A[i + limit]);
}
for(int j =0;j<limit;j++){
    ret.push_back(A[j]);
}

return ret; 

}