KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Here is one of my interview question. Given an array of N elements and where an element appears exactly N/2 times and the rest N/2 elements are unique . How would you find the element with a better run time? Remember the elements are not sorted and you can assume N is even. For example, input array [] = { 10, 2, 3, 10, 1, 4, 10, 5, 10, 10 } So here 10 appears extactly 5 times which is N/2. I know a solution with O(n) run time. But still looking forward to know a better solution with O(log n).
Tags (comma-separated)
Save Edits
Cancel