Python cheating manipulate values


  • 0

    '''
    class Solution(object):
    def rotateRight(self, head, k):
    """
    :type head: ListNode
    :type k: int
    :rtype: ListNode
    """
    if head is None:
    return head
    temp = []
    node = head
    while node is not None:
    temp.append(node.val)
    node = node.next
    k %= len(temp)
    temp = temp[len(temp) - k:] + temp[:len(temp) - k]
    node = head
    for i in temp:
    node.val = i
    node = node.next
    return head
    '''


Log in to reply
 

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