Implement Top-K Largest Elements

Given an integer array nums of length n and an integer k, return the largest k elements in the array, sorted in non-increasing order.

Requirements:

  • Do not sort the entire array dir...

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Standard Input
Execution Result: