0 out of 464 challenges solved
Write a Python function `find_n_largest(nums: List[int], n: int) -> List[int]` that takes a list of integers `nums` and an integer `n`, and returns the `n` largest integers from the list in descending order. If `n` is greater than the length of the list, return all elements sorted in descending order. #### Example Usage ```python [main.nopy] find_n_largest([25, 35, 22, 85, 14, 65, 75, 22, 58], 3) # Output: [85, 75, 65] find_n_largest([25, 35, 22, 85, 14, 65, 75, 22, 58], 2) # Output: [85, 75] find_n_largest([25, 35, 22, 85, 14, 65, 75, 22, 58], 5) # Output: [85, 75, 65, 58, 35] ``` #### Constraints - The input list `nums` will contain integers. - The value of `n` will be a non-negative integer. - The function should handle cases where `n` is 0 or greater than the length of the list.
from typing import List def find_n_largest(nums: List[int], n: int) -> List[int]: """ Returns the n largest integers from the list nums in descending order. Args: nums (List[int]): The list of integers. n (int): The number of largest integers to return. Returns: List[int]: A list of the n largest integers in descending order. """ # Placeholder for the solution pass