Last active
July 12, 2017 17:49
-
-
Save sreevidyavutukuru/d9a936a5c1a94e7fe07f4e140b2cb789 to your computer and use it in GitHub Desktop.
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
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