leetcode---1290.二进制链表转整数
作者:互联网
class Solution:
def getDecimalValue(self, head: ListNode) -> int:
if not head:
return 0
temp=[]
while(head):
temp.append(head.val)
head=head.next
l=len(temp)
ans=0
for i in range(l):
ans+=(temp[~i]*(2**i))
return ans
标签:---,head,return,temp,链表,ans,1290,append 来源: https://blog.csdn.net/m0_46384757/article/details/121888690