1 class Solution:
 2     def getDecimalValue(self, head: ListNode) -> int:
 3         res = 0
 4         lists = []
 5         while head != None:
 6             lists.append(head.val)
 7             head = head.next
 8         pos = 0
 9         for i in range(len(lists)-1,-1,-1):
10             res += lists[i] * (2 ** pos)
11             pos += 1
12         return res

 

posted on 2019-12-15 12:58  Sempron2800+  阅读(152)  评论(0编辑  收藏  举报