Solution for Reverse Linked List II

  • 0
    # Definition for singly-linked list.
    # class ListNode(object):
    #     def __init__(self, x):
    #         self.val = x
    # = None
    class Solution(object):
        def reverseBetween(self, head, m, n):
            :type head: ListNode
            :type m: int
            :type n: int
            :rtype: ListNode
            dummy = ListNode(0)
   = head
            cur = dummy
            for i in range(1, m):
                cur =
            tail =
            for i in range(m, n):
                if tail is None:
                tmp =
       = tmp

Log in to reply

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