Fastest way to search for an element in unsorted array

后端 未结 10 1802
北恋
北恋 2020-12-14 08:13

I just bumped on to this question today and was trying for a solution that is better than O(N) but could not come up with one.

Searched through SO but couldn\'t find

10条回答
  •  情书的邮戳
    2020-12-14 09:06

    You're right, the fastest way is to simply iterate through the array and look for it. Without further information, there is nothing better you can do.

    Unless you have a quantum computer, that is.

提交回复
热议问题