Why not using search one by one? 8ms, Accepted.

  • 0

    The worst run-time complexity is O(n) although using binary search, which increases complex of the code.
    Although binary search has O(logn) run-time complexity in average, too many operation and judgement make code hard to read, and cannot use cache of hardware, so it cannot reduce run-time too much.
    If consider such conditions above and give out a best solution, I prefer searching one by one.

  • 0

    Couldn't agree more

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.