# class ListNode: # def __init__(self, x): # self.val = x # self.next = None # # # @param head ListNode类 # @param m int整型 # @param n int整型 # @return ListNode类 # class Solution: def reverseBetween(self , head , m , n ): # write code here lis = [] p = head while(p): lis.append(p.val) p = p.next while(m<n): lis[m-1], lis[n-1] = lis[n-1], lis[m-1] m += 1 n -= 1 p = head for i in range(len(lis)): p.val = lis[i] p = p.next return head