Lol, Python


  • -1
    E
    class Solution(object):
        def rotateRight(self, head, k):
            if head:
                arr = self.list_to_array(head)
                k = k % len(arr)
                return arr[-k:] + arr[:-k]
            return None
        
        def list_to_array(self, head):
            result = []
            while head:
                result.append(head.val)
                head = head.next
            return result

Log in to reply
 

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