C++ O(N) || Swapping
Connect with me on LinkedIn: https://www.linkedin.com/in/abhay5349singh/\n\n\nclass Solution {\npublic:\n    \n    void reverse(vector<int> &a, int i, int j){\n
**Connect with me on LinkedIn**: https://www.linkedin.com/in/abhay5349singh/\n\n```\nclass Solution {\npublic:\n    \n    void reverse(vector<int> &a, int i, int j){\n        while(i<j){\n            swap(a[i],a[j]);\n            i++, j--;\n        }\n    }\n    \n    void rotate(vector<int> &a, int k) {\n        int n=a.size();   \n        \n        k%=n;\n        if(k<0) k += n;\n        \n        reverse(a,0,n-1);\n        reverse(a,0,k-1);\n        reverse(a,k,n-1);\n    }\n};\n```
['C++']