Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Definition for singly-linked list.
- # class ListNode:
- # def __init__(self, val=0, next=None):
- # self.val = val
- # self.next = next
- class Solution:
- def getDecimalValue(self, head: ListNode) -> int:
- res, curr = head.val, head
- while curr := curr.next:
- res = (res<<1) | curr.val
- return res
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement