def rotate_array(nums, n):
#TODO: Write - Your - Code sizee = len(nums)
sizee = len(nums)
temp_lst = []
temp_lst = nums[:sizee-n]
print('pre altered temp list is ', temp_lst)
for i in range(n):
temp_lst.insert(i,nums[sizee-n+i])
print("temp list is ", temp_lst)
nums = temp_lst
print("nums is ", nums)
return temp_lst
i was checking the console output and i have same as expected output (in case n > 0) , but platform is mentioning that test cases failed. Is there anything apparently wrong ?
Course: Coderust: Hacking the Coding Interview - Learn Interactively
Lesson: https://www.educative.io/courses/coderust-hacking-the-coding-interview/rotate-an-array-by-n-elements
Course: https://www.educative.io/courses/coderust-hacking-the-coding-interview
Lesson: https://www.educative.io/courses/coderust-hacking-the-coding-interview/rotate-an-array-by-n-elements