给定一个单链表,请把这个链表翻转下。
示例:输入 1->2->3 输出 1<-2<-3
class Node: def __init__(self, value=None, next=None) self.value = None self.next = None def reverse_linked_list(node): if node.next == None: return None cur_ptr, last_ptr = node, Node() while cur_ptr != None: temp_ptr = cur.next cur.next = last_ptr last_ptr = cur cur_ptr = temp_ptr