[Python] Leet Code 206. Reverse Linked List
본 내용은 를 참고했습니다. 자료형 변환 # Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def reverseList(self, lst: ListNode) -> ListNode: node, prev = lst, None while node: next, node.next = node.next, prev prev, node = node, next return prev def toList(self, node: ListNode) -> List: list: List = [] while node: lis..
더보기