Python code error


  • 0
    H
    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):
            k = -k
            return nums[k:] + nums[:k]
    

    Input: [1], 0
    Output: Do not return anything, modify nums in-place instead.
    Expected: [1]

    why not return?


  • 0
    S

    Is it required by the problem? You r supposed to rotate the original list rather than return a copy of that.


  • 0
    A

    The question doesn't require you to return a value.
    In the comments below the class Solution it states:

    # @return nothing, please modify the nums list in-place.
    

Log in to reply
 

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