K Most Frequent Elements
EPAMSoftServeGlobalLogic
Given an array of integers nums and an integer k, return the k most frequent elements. You may return the answer in any order.
Examples:
Input 1:
{"nums":[1,1,1,2,2,3],"k":2}Output 1:
[1,2]Input 2:
{"nums":[1],"k":1}Output 2:
[1]Loading editor...
Run your code to see results
Click the Run button above