We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7b2529e commit 59b9d59Copy full SHA for 59b9d59
LeetCode/189. Rotate Array/index.js
@@ -0,0 +1,8 @@
1
+var rotate = function(nums, k) {
2
+ let value = k % nums.length;
3
+ let splicePart = nums.splice(0, nums.length - value);
4
+ splicePart.map(item => nums.push(item));
5
+ return nums;
6
+};
7
+
8
+console.log(rotate([1, 2, 3, 4, 5, 6, 7], 3));
0 commit comments