Back to problems

Top K Frequent Elements (LC 347) with a Follow-Up Variant

Algorithm · Amazon · Medium

Top K Most Frequent Numbers Medium · Array, Hash Table, Bucket Sort · · Given an integer array nums and an integer k, return the k values that appear most frequently in the array. The result can be in any order. When multiple values share the same frequency and a full set of k cannot be formed without making arbitrary choices, any valid selection of k values among those with the highest frequencies is accepted. Follow‑up (streaming): Now suppose values from nums arrive one…

Checking your access…