Rotate list python


  • 0
    I

    I can't see find out what's wrong with my code

    class Solution:
    # @param head, a ListNode
    # @param k, an integer
    # @return a ListNode
    def rotateRight(self, head, k):
        l = len(head)
        newl = head[l-k:]
        newl.extend(head[:l-k])
        return newl
    if __name__ == '__main__':
        s = Solution()
        s.rotateRight([1,2,3,4,5,6],2)

  • 1
    L

    Please see the definitions of

    list

    and

    linked list

    ...


Log in to reply
 

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