Pop Tail
Start Timer
0:00:00
You are given two ListNodes of a doubly linked list. Write a function pop_tail which removes the tail of the linked list in time. Return the head and tail of the linked list as a list. If the linked list is empty after removal, return None.
A ListNode is defined as:
class ListNode:
value: ListNode = None
next: ListNode = None
prev: ListNode = None
Example:
Input:
3 -> 2 -> 4 -> 5 -> 7
head = ListNode(3)
tail = ListNode(7)
Output:
def pop_tail(head: ListNode, tail:ListNode) -> [ListNode(3), ListNode(5)]
.
.
.
.
.
.
.
.
.
Comments