题目描述:
提交:
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def getDecimalValue(self, head: ListNode) -> int: if not head: return 0 l = [] cur = head while cur: l.append(str(cur.val)) cur = cur.next res = "".join(l) res = int(res,2) return res