Back to problems

Sort Elements by Frequency

Algorithm · Amazon · Easy

You are given an integer array nums and an integer k. The exercise is about selection, not reordering: rather than returning the whole collection rearranged, you must extract the particular items the interviewer asks for. Three standard variants of this selection task exist, and the interviewer may switch between them, so confirm which one is in scope before you begin coding. Your submission must expose the entry point frequency_sort(nums, k). Variant 1 — k-th largest value,…

Checking your access…