206-Reverse-Linked-List
Sat 17 May 2025
https://leetcode.com/problems/reverse-linked-list
import pyutil as pyu
pyu.get_local_pyinfo()
print(pyu.ps2("python-dotenv"))
from typing import List
class Solution:
def reverseList(self, head: Optional[ListNode]) -> Optional[ListNode]:
if not head or not head.next:
return head
newHead = self.reverseList(head.next)
head.next.next = head
head.next = None
return newHead
new Solution().reverseList()
Score: 5
Category: leetcode