Метод 1: использование списка
# Assuming a list of recently watched titles
recently_watched_titles = ['Title A', 'Title B', 'Title C']
# Fetching the most recently watched title
most_recent_title = recently_watched_titles[-1]
print(most_recent_title) # Output: Title C
Метод 2: использование стека
# Assuming a stack of recently watched titles
recently_watched_titles = ['Title A', 'Title B', 'Title C']
# Fetching the most recently watched title
most_recent_title = recently_watched_titles.pop()
print(most_recent_title) # Output: Title C
Метод 3. Использование связанного списка
# Assuming a linked list of recently watched titles
class Node:
def __init__(self, title):
self.title = title
self.next = None
recently_watched_titles = Node('Title A')
recently_watched_titles.next = Node('Title B')
recently_watched_titles.next.next = Node('Title C')
# Fetching the most recently watched title
current_node = recently_watched_titles
while current_node.next:
current_node = current_node.next
most_recent_title = current_node.title
print(most_recent_title) # Output: Title C
Метод 4. Использование максимальной кучи
import heapq
# Assuming a max heap of recently watched titles
recently_watched_titles = ['Title A', 'Title B', 'Title C']
# Fetching the most recently watched title
most_recent_title = heapq.nlargest(1, recently_watched_titles)[0]
print(most_recent_title) # Output: Title C