Find a number where it appears exactly N/2 times

后端 未结 20 2157
旧巷少年郎
旧巷少年郎 2021-01-29 23:17

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

20条回答
  •  Happy的楠姐
    2021-01-29 23:35

    This is a poor interview question.

    1. You don't know the answer yourself.
    2. It doesn't have any business case behind it, so you will have difficulty explaining it to the candidate.

    Mostly because of the first one. What are you looking for? That the candidate should come up with this O(log n) solution you don't know exists? If you have to ask StackOverflow, is this something you can reasonably expect a candidate to come up with in an interview?

提交回复
热议问题