Why is this wrong?

  • 0
    class Solution:
        # @param nums, a list of integer
        # @param k, num of steps
        # @return nothing, please modify the nums list in-place.
        def rotate(self, nums, k):
            if len(nums) is 1:
                return nums
            result = []
            a = -1 * (k % len(nums))
            for i in range(len(nums)):
                a += 1
            return result

    This is my code, it work on my local for the case: [1, 2] 1

  • 0
    This post is deleted!

  • 0

    you should modify the 'nums', not just return the 'result'.

Log in to reply

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