Binary Search
Published:
While we discuss an algorithm problem, we focus on time and space complexity. O(n)
, linear time, is a good enough solution. There are a few methods that can beat linear time. However, binary search is one of the O(logN)
solutions. The timing that we can use the binary search is whether we discover some kind of monotonicity. Usually, a sorted structure problem is a fine candidate.