How can we rotate anti-clockwise using rotate function
Rotate function in stl
Hello @Tiwary725,
To rotate right, we need to subtract the vector index. For example, you have to rotate vector right 3 times. The 3th last index of vector becomes first element. vec.begin()+vec.size()-3 will rotate vector 3 times right.
SYNTAX:
rotate(vec2.begin(), vec2.begin()+vec2.size()-rotR, vec2.end());
Hope, this would help.
Give a like if you are satisfied.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.