TORONTO KIDS COMPUTER CLUB | PMCA Saturday 18:30 Python Homework 21.09.11.
19897
post-template-default,single,single-post,postid-19897,single-format-standard,ajax_fade,page_not_loaded,,qode-theme-ver-7.6.2,wpb-js-composer js-comp-ver-6.10.0,vc_responsive

PMCA Saturday 18:30 Python Homework 21.09.11.

15 Sep PMCA Saturday 18:30 Python Homework 21.09.11.

Question 1

A left rotation operation on an array of size  shifts each of the array’s elements  unit to the left. Given an integer,  write the code to rotate the array that many steps left and return the result.

Sample Input 1:
numSteps: 2
arr: [1,2,3,4,5]

Sample Output 1:
arr : [3,4,5,1,2]

Explanation:
In the array, we are left shifting the array by 2 steps. In the first steps, the first item in the array is moved to the end, so after the first step, the array will look as [2,3,4,5,1]. In the second steps, we will again move the first element of the array is moved to the end, so after the first step, the array will look as [3,4,5,1,2]

Sample Input 2
numSteps: 4
arr: [1,2,3,4,5]

Sample Output 2
arr: [5,1,2,3,4]

No Comments

Sorry, the comment form is closed at this time.