mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-05-02 06:46:18 -04:00
Update reverse_linked_list.py
This commit is contained in:
parent
17ca5877bf
commit
c004a953a9
1 changed files with 4 additions and 4 deletions
|
@ -2,15 +2,15 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# author: bt3gl
|
||||
|
||||
class ListNode:
|
||||
def __init__(self, val=0, next=None):
|
||||
class Node:
|
||||
def __init__(self, val=0, next):
|
||||
self.val = val
|
||||
self.next = next
|
||||
|
||||
|
||||
def reverse_list(head: Optional[ListNode]) -> Optional[ListNode]:
|
||||
def reverse_list(head: Optional[Node]) -> Optional[Node]:
|
||||
|
||||
if (not head) or (not head.next):
|
||||
if not head or not head.next:
|
||||
return head
|
||||
|
||||
new_head = reverse_list(head.next)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue