-
Notifications
You must be signed in to change notification settings - Fork 1
/
rotArrLeft.js
25 lines (16 loc) · 931 Bytes
/
rotArrLeft.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/*
A left rotation operation on an array shifts each of the array's elements 1 unit to the left. For example, if 2 left rotations are performed on array [1,2,3,4,5], then the array would become [3,4,5,1,2].
Given an array a of n integers and a number, d, perform d left rotations on the array. Return the updated array to be printed as a single line of space-separated integers.
Function Description
Complete the function rotLeft in the editor below. It should return the resulting array of integers.
rotLeft has the following parameter(s):
An array of integers .
An integer , the number of rotations.
*/
// Complete the rotLeft function below.
function rotLeft(arr, d) {
}
const test1 = [1,2,3,4,5];
console.log('rotLeft(test1, 2)', rotLeft(test1, 2)); // [3,4,5,1,2]
// console.log('rotLeft(test1, 5)', rotLeft(test1, 5)); // [1,2,3,4,5]
//abbrevaite word accesibility => a11y