Skip to content

Instantly share code, notes, and snippets.

@sreevidyavutukuru
Last active July 12, 2017 17:49
Show Gist options
  • Save sreevidyavutukuru/d9a936a5c1a94e7fe07f4e140b2cb789 to your computer and use it in GitHub Desktop.
Save sreevidyavutukuru/d9a936a5c1a94e7fe07f4e140b2cb789 to your computer and use it in GitHub Desktop.
def rotate( nums, k):
"""
:type nums: List[int]
:type k: int
:rtype: void Do not return anything, modify nums in-place instead.
"""
if len(nums)==1:
if k ==1:
return nums
mark = len(nums)-k
leng = len(nums)
result = []
for i in range(1,len(nums)+1):
result.append(0)
for i,val in enumerate(nums):
print val
if i+1 < mark:
result[i+k] = val
else:
result[(i)-leng+k] = val
return result
print rotate([1,2,3,4,5,6,7],3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment