This commit is contained in:
Gyubin Han
2025-02-19 14:09:55 +09:00
parent e3c6c8b32a
commit dede0dca01
36 changed files with 555 additions and 0 deletions

19
leetcode/206.py Normal file
View File

@@ -0,0 +1,19 @@
# 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, head: Optional[ListNode]) -> Optional[ListNode]:
l=[]
while not head==None:
n=ListNode(head.val)
l.append(n)
head=head.next
r=ListNode()
rt=r
while len(l)>0:
rt.next=l.pop()
rt=rt.next
return r.next