0 out of 464 challenges solved
Write a Python function `n_largest_items(lst, n)` that takes in a list `lst` of numbers and an integer `n`. The function should return a list containing the `n` largest items from the input list in descending order. #### Example Usage ```python [main.nopy] print(n_largest_items([10, 20, 50, 70, 90, 20, 50, 40, 60, 80, 100], 2)) # Output: [100, 90] print(n_largest_items([10, 20, 50, 70, 90, 20, 50, 40, 60, 80, 100], 5)) # Output: [100, 90, 80, 70, 60] print(n_largest_items([10, 20, 50, 70, 90, 20, 50, 40, 60, 80, 100], 3)) # Output: [100, 90, 80] ``` #### Constraints - The input list will contain at least `n` elements. - The input list may contain duplicate values. - The output list should be sorted in descending order.
from typing import List import heapq def n_largest_items(lst: List[int], n: int) -> List[int]: """ Returns the n largest items from the list in descending order. Args: lst (List[int]): The input list of integers. n (int): The number of largest items to return. Returns: List[int]: A list containing the n largest items in descending order. """ # Placeholder for the solution pass