Skip to content

Commit

Permalink
Time: 15 ms (92.24%) | Memory: 27.9 MB (31.55%) - LeetSync
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimple-01 committed Jun 12, 2024
1 parent 0a234f2 commit dd5c1b2
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions 189-rotate-array/rotate-array.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class Solution {
public:
void rotate(vector<int>& nums, int k) {

int n= nums.size();
vector<int> temp(n);
for(int i=0;i<n;i++)
{
temp[(i+k)% n]=nums[i];
}
for(int j=0;j<n;j++)
{
nums[j]=temp[j];
}
}
};

0 comments on commit dd5c1b2

Please sign in to comment.