The statement that we’ll be getting an array as an input [1,2,3,4,5] along with an integer (d). Then, we need to shift each of the array’s elements unit to the left. For example, if 2 left rotations are performed on an array [1, 2, 3, 4, 5], then the array would become [3, 4, 5, 1, 2].
Complete the rotateLeft function in the editor below. rotateLeft has the following parameters: ● Integer n denoted by size of array ● int d is the amount to rotate by ● int arr[n] is an array
5 4 1 2 3 4 5
5 1 2 3 4
When we insert arr [1, 2, 3, 4, 5] then after the left rotation perform it will show on console is, [2, 3, 4, 5, 1], so here it is mentioned that after 2 left rotation so now after another left rotation we found [3, 4, 5, 1, 2]