Skip to content
CampusEduX

K Largest Elements

Easyjavapythonccppjavascript

Given an integer array and K, find the K largest values.

Input Format

The first line contains two integers N and K. The second line contains N space-separated integers.

Output Format

Print the K largest values in decreasing order, separated by single spaces.

Related Problems

  • K Smallest Elements
    Easy · java, python, c, cpp, javascript
    Solve Problem
  • Implement Min Heap
    Medium · java, python, c, cpp, javascript
    Solve Problem
  • Implement Max Heap
    Medium · java, python, c, cpp, javascript
    Solve Problem

Input (stdin)

Output

Run your code to see output here...