Question DSA-ARR-0067
HardWhich algorithm finds the k most frequent elements of an array in O(n) expected time?
- A.
Binary search
- B.
Sort the array
- C.
Sign up free to see the answer and a step-by-step explanation.
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Arrays question
Which algorithm finds the k most frequent elements of an array in O(n) expected time?
Binary search
Sort the array
Sign up free to see the answer and a step-by-step explanation.
Use nested loops
Count frequencies with a hash map, then bucket the elements by frequency