1290. 二进制链表转整数








class Solution(object):
    def getDecimalValue(self):
        """
        :type head: ListNode
        :rtype: int
        """
        list = []
        while head:
            list.append(head.val)
            head = head.next
        list = list[::-1]
        ans = 0
        for i in range(len(list)):
            ans += list[i] * (2 ** i)
        return ans
原文地址:https://www.cnblogs.com/panweiwei/p/12857329.html