I’m trying to practice my Python on Leetcode. The question is 189. Rotate Array. Although it works correctly in other IDEs, It’s still wrong in Leetcode. Here is my Code:
class Solution:
def rotate(self, nums: List[int], k: int) -> None:
"""
Do not return anything, modify nums in-place instead.
"""
from collections import deque
nums = deque(nums)
for i in range(k):
nums.appendleft(nums.pop())
nums = list(nums)
print(nums)
Still don’t know. What’s the issue on my code?
New contributor
Lukas is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.