0
Write an algorithm that rotates a given array, Scenario
Write an algorithm that rotates a given array, Scenario Give an array b = [2,3,4,5] and rotation distance d = 2; when b is passed through rotation function myFunctions(arr: [Int], dist:Int) myFunction(arr: b, dist: d) result should should be [4, 5, 2, 3] the result can be printed or returned
4 odpowiedzi
+ 5
Hope Mwale ,
can you please complete your question by using a tag with the name of the required programming language ?
+ 3
Hope Mwale You have to post your try...
+ 2
I advise you to look at the modulo operator, it can be useful here.
You have to put a variable going from dist to (arr.size + dist - 1), and then adapt this variable to match with the array indexes
+ 1
First show your try!