Why this python code didn't pass the test?

  • 0
    class Solution(object):
        def rotate(self, nums, k):
            :type nums: List[int]
            :type k: int
            :rtype: void Do not return anything, modify nums in-place instead.

    Idea is the join the last half list and front half list together.

    First time I return nums[m:]+nums[:m] , but it's not what the test want. Then I simply change nums, but it didn't pass the test also.

  • 1

    List concatenation will create a copy

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.