Convert Binary Number in a Linked List to Integer
class Solution:
def getDecimalValue(self, head: Optional[ListNode]) -> int:
out = 0
while head:
out = 2 * out
out = out + head.val
head = head.next
return out