- LinkedList 안의 모든 수를 nums에 str 형태로 저장함.(∵ join 함수 사용)
- int로 변환.
# 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:
nums = []
while head != None :
nums.append(str(head.val))
head = head.next
nums = ''.join(nums)
return int(nums, 2)