To prove safety Offer 06

. 1 # - * - Coding: UTF- . 8 - * -
 2 # class ListNode:
 . 3  # DEF the __init __ (Self, X):
 . 4 # self.val = X
 . 5 # self.next = None
 . 6  
. 7  class Solution:
 . 8      # Returns value sequence from the tail to the head of the list, for example [ . 1 , 2 , . 3 ]
 . 9      DEF the __init __ (Self):
 10          self.result = []
 . 11          
12 is      DEF Track (Self, listnode):
 13 is          IF listNode.next:
 14             self.track(listNode.next)
15         self.result.append(listNode.val)
16             
17     def printListFromTailToHead(self, listNode):
18         if listNode:
19             self.track(listNode)
20         return self.result
21         # write code here

 

Guess you like

Origin www.cnblogs.com/asenyang/p/11013027.html