Created
March 27, 2017 16:24
-
-
Save kamal-github/65106059255614854f000ad52bfacc72 to your computer and use it in GitHub Desktop.
program-for-array-rotation-continued-reversal-algorithm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ex array | |
def rev_rotation_by_d(a, d) | |
d.times do | |
a << a.shift | |
end | |
a | |
end | |
def rotation_by_d(a, d) | |
d.times do | |
a.unshift(a.pop) | |
end | |
a | |
end | |
a = [3,4,5,1,2] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment