Skip to content

Commit

Permalink
이슈 #194에서 솔루션 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Dec 4, 2024
1 parent d46032b commit 5caef3b
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions LeetCode/Rotate_Array.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <algorithm>

using namespace std;

class Solution {
public:
void rotate(vector<int>& nums, int k) {
int n = nums.size();
vector<int> result(n);
k = k % n;

for (int i = 0; i < n; i++) {
result[(k + i) % n] = nums[i];
}

nums = result;
}
};

0 comments on commit 5caef3b

Please sign in to comment.