K Smallest Elements in an Unsorted Array

Problem: K Smallest Elements in an Unsorted Array

Given an unsorted integer array nums and an integer k, return the k smallest elements in the array.

To make the output deterministic, print...

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: