Skip to content

Commit 1d07bc7

Browse files
committed
feat: add array rotation algorithms
1 parent ce24cd4 commit 1d07bc7

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Data-Structures/Array/RotateArray.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/**
22
* Rotates an array to the right by k positions
3+
* @see https://en.wikipedia.org/wiki/Circular_shift
34
* @param {number[]} array - The array to rotate
45
* @param {number} k - Number of positions to rotate
56
* @returns {number[]} - New array rotated to the right by k positions
@@ -29,6 +30,7 @@ export function rotateRight(array, k) {
2930

3031
/**
3132
* Rotates an array to the left by k positions
33+
* @see https://en.wikipedia.org/wiki/Circular_shift
3234
* @param {number[]} array - The array to rotate
3335
* @param {number} k - Number of positions to rotate
3436
* @returns {number[]} - New array rotated to the left by k positions

0 commit comments

Comments
 (0)