Skip to content

Commit

Permalink
Rotate() method
Browse files Browse the repository at this point in the history
  • Loading branch information
WaderManasi committed Aug 10, 2020
1 parent ceff7e4 commit e5812ae
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions Standard Template Library/Rotating_ArrayLeft.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include <bits/stdc++.h>
#include<algorithm>
using namespace std;

vector<string> split_string(string);

// Complete the rotLeft function below.
void rotLeft(vector<int> a, int d) {

//rotate() method to left rotate elememts.
rotate(a.begin(),a.begin()+d,a.end());
for(int i=0;i<a.size();i++)
{
cout<<a[i]<<" ";
}
}

int main()
{
int val,n,rot;
cin>>n>>rot;
vector<int>v;
for(int i=0;i<n;i++)
{
cin>>val;
v.push_back(val);
}
rotLeft(v,rot);
return 0;
}

0 comments on commit e5812ae

Please sign in to comment.